Webdialog Question on .show
-
Hello, I was doing some testing with web dialogs and i came across something I was curious about.
I opened a new WebDialog of a simple html saved locally, within that HTML I had a hyperlink to another HTML file in the same directory, they link worked fine so I closed it down. However when I told the ruby console to show the webdialog again it was still on the second HTML page.
How does the webdialog know to open the second HTML file? It would seem it is storing its previous location somewhere, can anyone tell me where/how this works?
Cheers,
Korbin -
A webdialog is an object that presumably has variables of its own, one of them most likely being the current url.
In order to show the start page every time you show the dialog, you can reset the html path either straight in ruby, (WebDialog.set_html), or you can use onfocus or onload in the html file to load information.
--
Karen -
Thanks Karen,
I understand what your saying, however I am a bit more curious on how does the webdialog deal with multiple HTML files, I am building a series of functions in a .js file that connects to a number of HTML files and each HTML file will will send and receive data to Sketchup. Can one webdialog object send and receive these commands to the correct page seeing how it seems to keep track of which page one is on? Or will things start to get a bit hairy
Cheers
Korbin -
A webdialog is 'current' until you
.close
it when it is no longer visible.
So if you re-.show
it then it becomes visible gain, displaying the last used settings.
To go back to the original settings you need to.close
the first one and then make a new dialog with the same starting point and.show
that. -
Make sure to read WebDialogs - The Lost Manual (by ThomThom)
The webdialog is an instance of your custom WebDialog class. When you
.close()
the window, the instance object still exists, and when you.show()
it your only opening up the window again.On PC you can use the block argument to do something in the javascript. (It is bugged on the Mac.)
<span class="syntaxdefault">webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault"> webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">execute_script</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"window.location='startpage.html';"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /></span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span>
Advertisement