Window.open webdialog on MAC close parent
-
Hi,
I'm trying to make a plugin MAC compatible, and I can't open a child window of a webdialog.
window.open does not have same behaviour on MAC and it open a child window in parent window closing parent I think.
Someone knows why donesn't work on MAC.dialog = UI;;WebDialog.new("PVGYS", true, "sk_pvgys", 930, 830, 500, 0, true) dialog.set_url('http://re.jrc.ec.europa.eu/pvgis/apps3/pvest.php') dialog.show(){ dialog.execute_script("myWindow=window.open('','output','left=0 width=550,height=800,scrollbars=1,resizable=1');") }
-
Not sure if I remember right, but I wonder if .show's block executes before the HTML is ready - or not at all..
Better to use the onload event in JS to perform actions.
-
It does not matter. Behaviour of window.open is the same.
path = Sketchup.find_support_file("windowopen.html" ,"Plugins/") dialog = UI;;WebDialog.new("PVGYS", true, "sk_pvgys", 930, 830, 500, 0, true) dialog.set_file(path) dialog.show(){}
test.rb
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> myWindow=window.open('','output','left=0 width=550,height=800,scrollbars=1,resizable=1'); </script> </head> <body> Main window </body> </html>
windowopen.html
-
Thinking of it, I didn't think the
window
object was available at all for WebDialogs.Not sure what is going on. Don't have a Mac at hand right now. But an alternative is to open a new WebDialog instead...
-
What about:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> var myWindow; init(){ myWindow=window.open('','output','left=0,width=550,height=800,scrollbars=1,resizable=1'); } </script> </head> <body onload="init;"> Main window </body> </html>
(There was a comma missing after "left=0")
P.S.: We do know that window.opener returns "nil or not a method" error for WebDialogs.
-
@juantxo said:
Hi,
Someone knows why donesn't work on MAC.What's not working, Initially the site is loaded and shows.
immediately the last item loads it closes the main site and opens an 'about blank' page at the new screen coordinates with the original window title and no content, as none is supplied.
What's it meant to do???
@Dan> defined? window.opener nil
john -
@driven said:
@Dan
> defined? window.opener nil
It's not a Ruby statement... it's Js (that's why I made it purple.)
Meaning that in a normal browser, if your page code opens a child window, the child window's page code can get it's parent window (the browser, or whatever,) by calling window.opener.
But we attempted to get the Sketchup application window, by calling that in the WebDialog's page code, but it raises a Js error. (If you recall, this was back when we were trying to make WebDialogs act like toolbars.)
-
@unknownuser said:
(http://msdn.microsoft.com/en-us/library/ms536651(v)":19letvmf]Internet Explorer 7 on Windows Vista. Opening a new window from an application other than the Internet Explorer process may result in a NULL return value. This occurs because Internet Explorer runs in protected mode by default. Protected mode prevents applications from privileged access to Internet Explorer when that access spans process boundaries. Because this method opens windows in a new process, protected mode restricts access to the new window. For more information, please see Understanding and Working in Protected Mode Internet Explorer.
Internet Explorer 6 for Windows XP SP2 places several restrictions on windows created with this method. For several of the parameter values listed in the Parameters table, these restrictions are indicated by the minimum value. For more information, see About Window Restrictions.
This method must use a user-initiated action, such as clicking on a link or tabbing to a link and pressing enter, to open a pop-up window. The Pop-up Blocker feature in Internet Explorer 6 blocks windows that are opened without being initiated by the user. The Pop-up Blocker also prevents windows from appearing if you call this method from an onunload event.
-
Did you try the [createPopup](http://msdn.microsoft.com/en-us/library/ms536651(v) Method ??
-
Ok,
if I just rundialog = UI;;WebDialog.new("PVGYS", true, "sk_pvgys", 930, 830, 500, 0, true) dialog.set_url('http://re.jrc.ec.europa.eu/pvgis/apps3/pvest.php') dialog.show_modal
I can go to child windows and then right click to go back to the parent etc...
I get an error for each because the request is asking for a new TAB not window, but because this WebDialog doesn't have Tabs, The new windows appear to be sized by the content.
[@Dan, you highlight so often for so many reasons I loose track... and I tend to paste rather than read...]
john -
@unknownuser said:
What's not working
Using javascript command "myWindow = window.open();" in Safari and IE you have two windows opened.
But inside a webdialog this command in MAC not open a new window, only load it inside parent window. In IE works normally, and you have two windows at same time.
I give up with this, I achieved the plugin to work in MAC whith only one window.
Thank you all
-
Why not just open a new WebDialog?
-
I want to open this webdialog 'http://re.jrc.ec.europa.eu/pvgis/apps3/pvest.php' and when I press "calculate" the server
sends a response, opened in a new window (in Safari and IE), but not in MAC webdialogs.
I only wanted to know why window.open() works differently in MAC webdialogs, nothing more.
(I can't modify server files) -
Hi Jauntxo,
The reasons for WebDialogs and Safari behaving differently [on the same machine] are two fold.
1: WebDialogs can't and don't use Safari.app,
Safari is a separate Apple application that also uses WebKit and WebCore frameworks.Sketchup UI can use Safari.app
Safari = UI.openURL "http://re.jrc.ec.europa.eu/pvgis/apps3/pvest.php"
Opens your target in Safari.
2: When using WebDialogs, you are being routed through Sketchup server settings.
Sketchup generates the headers based on the best way for it to access dynamic Google Resources [SU Licensing, G Warehouse, G Earth, etc...]If you point WD at a dynamic site that has a different structure to the Sketchup<=>Google template your results will vary.
Even going to the SU API pages from inside SU is problematic.However, the pages you want to access are nicely constructed and can be accessed and work from a Webdialog.
The settings may vary from the ones for PC, but with a couple of slight impositions this works.dlg = UI;;WebDialog.new("PVGIS", true,"pvgis", 900, 930, 150, 150, true, true); dlg.set_url "http://re.jrc.ec.europa.eu/pvgis/apps3/pvest.php" dlg.min_width = 900 dlg.min_height = 930 dlg.max_width = 900 dlg.max_height = 930 dlg.set_position(150,150) dlg.navigation_buttons_enabled=true dlg.show_modal
With these settings you can do all your navigation from one window, and use the back/forward buttons for most things [Back after PDF doesn't work].
If you are sent to a different width page, the WD will narrow, but when you grab the corner it will resize to the defined max/min settings.
All the 'onscreen' information appears to work.
Selecting 'Text' as output doesn't appear to work. [in a quick test], but PDF output can be saved locally from the WD.Hope this helps answer your query.
john -
Today I finish to change Skelion plugin to run on MAC and it seems all is running ok.
Thank you John. -
SO.. the lesson is, do not try and open a new window from the webdialog JS.. instead write a Ruby callback and fire it FROM the JS, .. and let the Ruby callback open the window using either
UI.openURL
or instantiating anotherWebDialog
instance. -
@unknownuser said:
SO.. the lesson is, do not try and open a new window from the webdialog JS..
not necessarily SO..
Dynamic Components works fine writing new windows. SU, as both client and server allows for it.
Get Photo Textures can go full screen with 'Flash', because SU allows for it.Creating new windows in js works, it's just needs special handling to deal with resizing.
If you add the back/home/forward buttons you can have multiple new windows, all packed neatly into one chrome.
What you can't do via 'SU as Server' is Download or Upload local content. [that's what broke set_html if html = local_file.img]
@unknownuser said:
instead write a Ruby callback and fire it FROM the JS, .. and let the Ruby callback open the window using either UI.openURL or instantiating another WebDialog
Curiously, in mac SU, GoogleEarth.app is controlled by an Applescript, that sets and gets contents, takes a screenshot and inserts that it back into SU.
I had a go an applescript version for this topics site last night that uses
UI.openURL
to open in Safari but positioned [by script] 'as if' in SU.I then manually filled in the form and downloaded the text file.
I then used a folder action to automatically move and rename the new file to match a WD
dlg.set_file "path/text.txt"
to
open in SU. [WD even wraps it in <pre with formating> automatically].You could do the Safari stuff in the background, including filling in the form fields, requesting the calculation and download.
SO.. you could use SU to launch a WD1 to collate all the required input,
then have SU complete an Applescript with that information before running that script [in own thread] via system
WD1 could spin a progress bar until the new file is available.
then SU can launch a WD2 with the required output, closing WD1 as it opens.john
-
@driven said:
What you can't do via 'SU as Server' is Download or Upload local content. [that's what broke set_html if html = local_file.img]
Is this local content still broken on Safari ??
-
Advertisement