Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. IE window.open with the window Modal

IE window.open with the window Modal

Scheduled Pinned Locked Moved ASP.NET
toolsannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    Dr_X
    wrote on last edited by
    #1

    I have an IE window that has a script added upon postback to do a window.open on a text file. However, when I use page.RegisterStartUpScript or page.RegisterClientScriptBlock to execute the window.open script after postback the new window opens behind the parent form. I have to do the postback as users may update data prior to exporting to a text file. I did see the modal option for window.open but it does not work with IE. Any ideas or alternative methods I should try. Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

    M 1 Reply Last reply
    0
    • D Dr_X

      I have an IE window that has a script added upon postback to do a window.open on a text file. However, when I use page.RegisterStartUpScript or page.RegisterClientScriptBlock to execute the window.open script after postback the new window opens behind the parent form. I have to do the postback as users may update data prior to exporting to a text file. I did see the modal option for window.open but it does not work with IE. Any ideas or alternative methods I should try. Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Do you have anything running after the window.open method runs? For example, you are trying to keep the focus on the previous input entry on the main web form ...If this is the case, you simply need to set the focus on the child window in the handler of the body's onload event of the main page.

      //You need to save the reference to the child window in a global variable:
      childWindowRef = window.open('info.txt');

      ....
      function Body_Onload()
      {
      if(childWindowRef)
      {
      childWindowRef.focus();
      }
      }

      D 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, Do you have anything running after the window.open method runs? For example, you are trying to keep the focus on the previous input entry on the main web form ...If this is the case, you simply need to set the focus on the child window in the handler of the body's onload event of the main page.

        //You need to save the reference to the child window in a global variable:
        childWindowRef = window.open('info.txt');

        ....
        function Body_Onload()
        {
        if(childWindowRef)
        {
        childWindowRef.focus();
        }
        }

        D Offline
        D Offline
        Dr_X
        wrote on last edited by
        #3

        Thanks, as I have already tried that. The form flashes with focus but immediately goes back to the parent. I am assuming it is because the parent had to continue to load after the RegisterStartUpScript had executed the window.open. Not sure but aggrevating. Do a postback on a form then register a window.open script and see if the child can keep the focus. Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

        M 1 Reply Last reply
        0
        • D Dr_X

          Thanks, as I have already tried that. The form flashes with focus but immediately goes back to the parent. I am assuming it is because the parent had to continue to load after the RegisterStartUpScript had executed the window.open. Not sure but aggrevating. Do a postback on a form then register a window.open script and see if the child can keep the focus. Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Yes, you're right. The parent keeps loading after the window.open executes. When the browser parses the markup of the document, if it encounters the script tag generated by the Page.RegisterStartUpScript, it will execute the client side code inside in the tag script, then try to load the next element. Another way comes to mind which I'm not sure if you have tried it yet. That is we can try to open a new child window only after the main page is loaded.

          //Emit the script to open the child window.
          string script = "function OpenChildWindow(){window.open('info.txt')};";
          Page.RegisterStartupScript("StartUpScript", script);
          ....

          function Body_Onload()
          {
          if (typeof(OpenChildWindow) == 'function')
          OpenChildWindow();
          }

          D 1 Reply Last reply
          0
          • M minhpc_bk

            Yes, you're right. The parent keeps loading after the window.open executes. When the browser parses the markup of the document, if it encounters the script tag generated by the Page.RegisterStartUpScript, it will execute the client side code inside in the tag script, then try to load the next element. Another way comes to mind which I'm not sure if you have tried it yet. That is we can try to open a new child window only after the main page is loaded.

            //Emit the script to open the child window.
            string script = "function OpenChildWindow(){window.open('info.txt')};";
            Page.RegisterStartupScript("StartUpScript", script);
            ....

            function Body_Onload()
            {
            if (typeof(OpenChildWindow) == 'function')
            OpenChildWindow();
            }

            D Offline
            D Offline
            Dr_X
            wrote on last edited by
            #5

            Thanks minhpc_bk!!! That did the trick. Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups