简体   繁体   中英

Popup window losing focus

I have a print preview button on an asp.net page that opens a new window with a pdf version of what's currently on the screen so the user can print it out. However, this window loses focus because an iframe on the parent page refreshes itself after the popup page loads. Is there any way to keep the iframe from refreshing or to restore focus to the popup?

Below is the code I'm using to open the new window.

Dim url As String = "frmPrintPreview.aspx"
                btnPrintPreview.OnClientClick = "Javascript:window.open('" & url & "','printpreview','height=420,width=550,toolbar=yes,status=yes,scrollbars=yes,resizable=yes');"

This is the code for the iframe:

<iframe id="FrameLeft" runat="server" name="FrameLeft" scrolling="no" style="border-right: silver 1px inset;
                    border-top: silver 1px inset; z-index: 110; left: 603px; border-left: silver 1px inset;
                    width: 464px; border-bottom: silver 1px inset; position: absolute; top: 32px;
                    height: 675px" visible="false"></iframe>

Try this:

Dim url As String = "frmPrintPreview.aspx"
                btnPrintPreview.OnClientClick = "Javascript:var win = window.open('" & url & "','printpreview','height=420,width=550,toolbar=yes,status=yes,scrollbars=yes,resizable=yes'); setTimeout(win.focus, 0);"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM