• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Window.open webdialog on MAC close parent

Scheduled Pinned Locked Moved Developers' Forum
19 Posts 4 Posters 586 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    Juantxo
    last edited by 15 Feb 2012, 09:54

    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');") 
     }
    
    
    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 15 Feb 2012, 10:23

      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.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • J Offline
        Juantxo
        last edited by 15 Feb 2012, 11:20

        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

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 15 Feb 2012, 11:41

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

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 15 Feb 2012, 12:28

            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.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by 15 Feb 2012, 22:45

              @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

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 15 Feb 2012, 23:30

                @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.)

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 15 Feb 2012, 23:37

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

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 15 Feb 2012, 23:42

                    Did you try the [createPopup](http://msdn.microsoft.com/en-us/library/ms536651(v) Method ??

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by 15 Feb 2012, 23:59

                      Ok,
                      if I just run

                      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_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

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Juantxo
                        last edited by 17 Feb 2012, 11:57

                        @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

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          thomthom
                          last edited by 17 Feb 2012, 12:02

                          Why not just open a new WebDialog?

                          Thomas Thomassen — SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            Juantxo
                            last edited by 17 Feb 2012, 12:27

                            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)

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              driven
                              last edited by 17 Feb 2012, 15:58

                              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

                              learn from the mistakes of others, you may not live long enough to make them all yourself...

                              1 Reply Last reply Reply Quote 0
                              • J Offline
                                Juantxo
                                last edited by 17 Feb 2012, 16:20

                                Today I finish to change Skelion plugin to run on MAC and it seems all is running ok.
                                Thank you John.

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  Dan Rathbun
                                  last edited by 17 Feb 2012, 16:45

                                  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 another WebDialog instance.

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    driven
                                    last edited by 18 Feb 2012, 23:43

                                    @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

                                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      Dan Rathbun
                                      last edited by 21 Feb 2012, 04:12

                                      @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 ??

                                      I'm not here much anymore.

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        thomthom
                                        last edited by 21 Feb 2012, 08:38

                                        @dan rathbun said:

                                        @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 ??

                                        Yes. 😞

                                        Thomas Thomassen — SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

                                        1 Reply Last reply Reply Quote 0
                                        • 1 / 1
                                        1 / 1
                                        • First post
                                          1/19
                                          Last post
                                        Buy SketchPlus
                                        Buy SUbD
                                        Buy WrapR
                                        Buy eBook
                                        Buy Modelur
                                        Buy Vertex Tools
                                        Buy SketchCuisine
                                        Buy FormFonts

                                        Advertisement