Webdialogs on Mac.

Webdialogs on Mac.

Postby CPhillips » Sun Mar 23, 2008 3:16 am

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.

Code: Select all
        $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
0

CPhillips 
PluginStore Author
PluginStore Author
 

Re: Webdialogs on Mac.

Postby todd burch » Sun Mar 23, 2008 4:45 am

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
0

todd burch 
 

Re: Webdialogs on Mac.

Postby CPhillips » Sun Mar 23, 2008 5:26 am

Todd Burch wrote: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:
Code: Select all
dialog.execute_script("window.alert('hello')")

That works on Windows shouldn't it work on Mac?
0

CPhillips 
PluginStore Author
PluginStore Author
 

Re: Webdialogs on Mac.

Postby todd burch » Sun Mar 23, 2008 1:17 pm

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.
0

todd burch 
 

Re: Webdialogs on Mac.

Postby enjahova » Wed Mar 11, 2009 4:37 am

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!
0

enjahova 
 

Re: Webdialogs on Mac.

Postby ScottLininger » Thu Mar 12, 2009 6:50 pm

Bugs noted. Thanks, guys!

We fixed some WebDialog mac bugs with 7.0, but there's obviously still work to be done.

Cheers,
0
- Scott Lininger
SketchUp Software Engineer
Have you visited the Ruby API Docs?
User avatar
ScottLininger 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 7 guests

Visit our sponsors: