<\/script>')

How to open a new window in asp.net?

I want to open a new window when I click a button. I used the code.

Response.Write("<script type='text/javascript'>detailedresults=window.open('YOURPAGE.aspx','_blank');</script>")

It behaves like a popup, but it does not work in IE 7.0 and Chrome. Please help me solve this problem. Thanks in advance.

+3
source share
3 answers

In most modern browsers, the browser will prevent a pop-up window if javascript was not launched as a result of user action. Actions like onClick are fine, but a script that runs as soon as the page loads will usually be blocked.

NTN, Brian

+2
source

Why not set the target to _blank on the anchor tag instead of the button? eg.

<a href="yourpage.aspx" target="_blank" />

Does this work for you?

+1

- , , , .

You can only have a popup if it is a direct response to a user event (for example, in the onclick handler).

You cannot enable inclusion on page loading.

+1
source

Source: https://habr.com/ru/post/1778732/


All Articles