IE window.open with the window Modal
-
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)
-
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)
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'sonload
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();
}
} -
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'sonload
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();
}
}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)
-
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)
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();
} -
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();
}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)