Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Focus

Status
Not open for further replies.

arundahar

Programmer
Apr 27, 2001
53
GB
Hi, i have a webpage that in turn calls a window.open command on a new URL (generating a pop-up window) and refreshes itself.

Basically focus is being returned when the pop-up is another webpage, but when i try to open a pop-up linking to a PDF the focus is lost.

The pop-up loads up, switches to the background and the main page retains focus, thus hiding the PDF page behind it.

Here's my code:

function retainfocus(strRel, strLink)
{
var objWin;
objWin = window.open(strRel, strLink);
objWin.focus();
return objWin;
}

The button that the User presses has this as it's <a href>:

<a href=&quot;javascript:document.registercheck2.submit();retainfocus('../..' + '<%=strProductLink%>');&quot;>

I thought that switching the form submit and the retainfocus() functions would help but it doesnt...

Any help would be great,

Thanks

Arun
 
you seem to be submitting a form in the same action as launching the pdf. The script is working fine however the form submit is probably coming back after the popup window has recieved focus and therefore focus is put back on the main window.

if you want the pdf to stay on top why not make it a modal dialog
 
err modal dialog...please expand...and explain!!

Cheers..

I cannot write anything to the pop-up window by the way. The pop-up could be a few file types (html, asp, pdf, xls) etc..

There's obviously something happening when loading the pdf as opening other webpages works fine and the pop-up retains focus...

 
modal will prevent the parent window from getting focus until the popup is closed.

window.showModalDialog(&quot;...&quot;)


or try changing your a tag to:

<a href=&quot;#&quot; onclick=&quot;document.registercheck2.submit();retainfocus('../..' + '<%=strProductLink%>');return false&quot;>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top