Why doesnt this ExecuteJavascript work?

Im just trying to do some simple styling using ExecuteJavascript in an opening event for a rectangle. It doesn’t seem to be working. Any help with why this doesnt work? Here is the code:

Me.ExecuteJavascript("document.getElementById('" + Me.ControlID + "').style.border-thickness:5px")

Thanks for the help!

Why not do something like…

ControlName.Style.Value(“border-thickness”) = “5px”

No JavaScript needed :slight_smile:

Tried adding that into the open event just now and it doesnt work. Every piece of it throws an error. The primary error is ControlName.Style.Value does not match any available signatures. I added WebPageHomeBGRect.Style.Value(“border-thickness”) = “5px”. Not sure what Im doing wrong.

Ok I got it running. Not sure how but I found it in the reference and copied that and changed to just how you had it and it works. No clue what I did wrong. But, when I run it, it still doesnt seem to have an effect on the control.

It needs to run on or after the shown event for the control before it can be modified.

Makes perfect sense! Working now! Thanks guys!

1 Like

Should probably be:

But my JS is a bit rusty these days.

2 Likes

That’s almost right, but it should be

borderThickness

Lowercase ‘b’

4 Likes
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.