sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

    WebDialog vs. Win7/IE10 problem

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 4 Posters 818 Views 4 Watching
    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.
    • L
      lendle
      last edited by

      Dear sir:
      I faced a problem with win7/IE10 combination. In my project, there is a need to get large string from a WebDialog. I know get_element_value should be used. However, on my win7 machine with IE10, get_element_value always return nil. I've tried using META information to force IE version from 7~10 but still in vain. The same program works with error on a Mac/Safari combination.
      I'm looking forward to suggestions, thank you!

      Regards,
      Lendle Tseng

      1 Reply Last reply
      Reply Quote 0
      • thomthomT
        thomthom
        last edited by

        Sounds like you're not providing the correct ID name to the INPUT element.

        Got a sample snippet that fails?

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

        1 Reply Last reply
        Reply Quote 0
        • L
          lendle
          last edited by

          Thanks for the reply. The id/name of the input element is correct since the same program runs fine on a Mac/Safari environment. Below is the code snippet:

          HTML:

          <html>
              <head>
                  <meta http-equiv="X-UA-Compatible" content="IE=7"/>
              </head>
          	<script type="text/javascript">
          		function test1(){
                                  document.getElementById("data1").value="123456";
          			window.location.href="skp;ruby_messagebox@";
          		}
          	</script>
          	<body>
          		<a href="javascript&#058;test1()">12345</a>
          		<input type="hidden" id="data1" name="data1" value="123">123456</input>
          	</body>
          </html>
          

          Ruby:

          tool_menu.add_item("HelloWorld Tool") {
             dlg = UI;;WebDialog.new("Show Sketchup.com", true, "ShowSketchUpDotCom", 739, 641, 150, 150, true);
             dlg.add_action_callback("ruby_messagebox") {|dialog1, params|
          	   UI.messagebox(dialog1.get_element_value("data1"))
          	 }
          
             dlg.set_url "http://localhost;8080/SketchupWeb/"
             dlg.show
             UI.messagebox(dialog1.get_element_value("data1"))
          }
          

          Thank you!

          Regards,
          Lendle Tseng

          1 Reply Last reply
          Reply Quote 0
          • L
            lendle
            last edited by

            @thomthom said:

            Sounds like you're not providing the correct ID name to the INPUT element.

            Got a sample snippet that fails?

            Dear sir, thanks for reply.
            Th ID/Name of the input element is correct and the program works on Mac/Safari.

            1 Reply Last reply
            Reply Quote 0
            • jolranJ
              jolran
              last edited by

              Just for the record, don't use UI.messagebox for debugging. Sometimes it fails silently.

              1 Reply Last reply
              Reply Quote 0
              • L
                lendle
                last edited by

                @jolran said:

                Just for the record, don't use UI.messagebox for debugging. Sometimes it fails silently.

                Dear sir:
                Thanks for the reply. The UI.messagebox part does not fail. It just display an empty string.
                By the way, the program works well on Mac/Safari. It just fails on Win7/IE10.

                Regards,
                Lendle Tseng

                1 Reply Last reply
                Reply Quote 0
                • thomthomT
                  thomthom
                  last edited by

                  After you call webdialog.show the HTML content isn't necessarily ready.

                  I think that there are differences between OSX and Windows when it prepares the content. If I remember right, under OSX the HTML and DOM seem to be prepared as you use .set_html, .set_file or .set_url. Under windows it's done first when you call .show.

                  What you need to do is set up a callback from JS when the DOM is ready to notify the webdialog - then after that you can pull data from the webdialog.

                  I wrote about it in the Lost Manual: https://github.com/thomthom/sketchup-webdialogs-the-lost-manual/wiki/window.onload

                  I should add an example of how to wait for the DOM to be ready.

                  Javascript - Assuming you use jQuery

                  
                  $(document).ready(function() {
                    window.location = 'skp;Window_Ready';
                  } );
                  
                  

                  WebDialog:

                  
                  webdialog = UI;;WebDialog.new
                  webdialog.add_action_callback('Window_Ready') { |wd, params|
                    wd.get_element_value('data1')
                  }
                  webdialog.show
                  
                  

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

                  1 Reply Last reply
                  Reply Quote 0
                  • A
                    Aerilius
                    last edited by

                    As Thomthom said, a webdialog is created asynchronously because it could take time (at least for programmers, this is much valuable time). That means Ruby should not wait until the webdialog is visible, but it continues immediately with the next line of code. That is the reason why the Ruby API uses code blocks ( add_action_callback("action"){} or show{}). The last one is known to be buggy. The best practice is to call a callback after the body of the html file (when the complete DOM is loaded).

                    Offtopic: I recently noticed that modal webdialogs in the Windows version of SketchUp seem to be synchronous and stop executing Ruby code until the dialog is closed. I wouldn't rely on it, but it can be helpful for (unit) testing.

                    1 Reply Last reply
                    Reply Quote 0
                    • thomthomT
                      thomthom
                      last edited by

                      Yes, modal webdialogs under Windows are working as modal windows should. For some odd reason it's not working as a modal window under OSX.

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

                      1 Reply Last reply
                      Reply Quote 0

                      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 Login
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement