Webdialogs on Mac.
-
I am having some problems getting a Webdialog to work on Mac. The problem is that execute_script()function doesn't seem to do anything on Mac. The following code is adapted from the documentation. It works on Win but doesn't do anything on Mac.
$testdialog=UI;;WebDialog.new("Test", true,"testkey", 250, 600, 600, 250, true) html='<HTML><HEAD></HEAD><body><div id="testdiv"></div></body></HTML>' $testdialog.set_html(html) $testdialog.show { java='document.getElementById("testdiv").innerHTML="Hello World"' $testdialog.execute_script(java) }Am I doing something wrong? Can anyone confirm that execute_script works on Mac?
Thanks
Chris -
execute_script works on a Mac.
Before you do that, try adding a semi colon to the end of your javascript clause. If that won't do it, put your getElementById stuff in a function, and call the function via execute_script, passing whatever you want to set the innerHTML to as the parm.
execute_script works better than set_html. Use set_file on a Mac and it'll work every time.
Todd
-
@unknownuser said:
execute_script works on a Mac.
Before you do that, try adding a semi colon to the end of your javascript clause. If that won't do it, put your getElementById stuff in a function, and call the function via execute_script, passing whatever you want to set the innerHTML to as the parm.
execute_script works better than set_html. Use set_file on a Mac and it'll work every time.
Todd
I have narrowed it down a bit. I can call javascript functions that are already defined in a html but I cant get access to "document" or "window" directly. I can and will write wrappers if I need to. But it would be a pain.
I tried adding a semicolon to the line above and it made no difference. In fact semicolons seem to cause problems in certain cases on Mac.
execute_script("somefunc('hello');")
Calls the javascript func with the string: "hello);" on Mac. But if I leave the semicolon off it seems to work as intended.
In my real app I am using set_file. The example was a stripped down case.
Here is an even simpler case:
dialog.execute_script("window.alert('hello')")That works on Windows shouldn't it work on Mac?
-
Yes, it should work on a Mac. I lost track of how many webdialog bugs I've reported to Google, that they have also acknowledged.
-
I ran into a problem on OS X, Sketchup version 7 where the execute_script worked, but the WebDialog wouldn't refresh.
I noticed an alert(); would refresh it, but that would be annoying so this was my workaround:
in your javascript callback function put:
window.location.href = "#someanchor"which will reload your webdialog on the original page, with all the .innerHTML's executed!
-
Bugs noted. Thanks, guys!
We fixed some WebDialog mac bugs with 7.0, but there's obviously still work to be done.
Cheers,
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement