JavaScript focus() does not work on IE
I have an ASP.NET 2.0 page with a button that opens a popup with FileUpload dialog. The code below is doing that.
In Chrome and FireFox popup opens and stays in focus, as intended. However, in IE6 and IE7 it opens but then the main window gets in front of it.
How can I change my JavaScript building code in C# to keep that popup on top in IE7 (our standard browser)?
Thanks
/// Javascript Open Popup Window Method
Code:
_sb.AppendLine("function openPopup(url) {");
_sb.AppendLine(" popup = window.open(url,'FileUpload','height=200,width=420,resizable=yes');");
_sb.AppendLine(" if (window.focus) {popup.focus()}");
_sb.AppendLine("}");
_sb.AppendLine(String.Format("openPopup('{0}');", "FileUpload.aspx"));
Re: JavaScript focus() does not work on IE
I would make it so that the popup receives focus regardless of the other windows focus.
Re: JavaScript focus() does not work on IE
here is working solution (in the popup window):
<body onload="setTimeout('self.focus()', 10)">
thanks