How to open popup Page in New tab
11,264
You will need to make the JavaScript call a user initiated event.
Please see this question and answer for further details (specifically, see point 3 in the answer).
Working example.
<input type="button" value="Click Me" onclick="openWindow()" />
function openWindow() {
window.open('http://www.google.com/', '_blank');
}
Author by
Sumanta
Updated on June 04, 2022Comments
-
Sumanta almost 2 years
I am using below code for open page in popup window.
ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow", "window.open('URL');", True)
But i want to page open in New Tab. Can any one help me in that.
-
Sumanta about 10 yearsThis code is not working. I tried this code but page is not open. My code is working but it open Popup window i want to open New Tab.
-
Sumanta about 10 yearsi am using Chrome browser and i have done the setting.
-
voddy about 10 yearsTry using IE and see if its the same. This is defenitely some browser setting
-
Shirish about 10 years@angsuf yr answer is good. i have smiler prob --> can u say how to do this operation from code file because this thing causing popup and that popup block by browser.. we have to manually allow popup then after it work..
-
angus about 10 years@Shirish do you mean to open a new window from the code behind or do you mean to create the JavaScript function and set the onclick attributes from the code behind?
-
Shirish about 10 years@angsuf yes i want to open new window from code behind, I am using like this function.. ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open('../default.aspx','_blank');", true); but every time it cause popup and browser blocker block popup in all browsers..
-
angus about 10 years@Shirish your code is just running the script to open the popup on the page load. A user will need to initiate the popup using a control that calls the JavaScript function. The answer I provided is relevant to you also. Point 6
6. Some popup blockers will allow windows opened from user initiated events, but not those opened otherwise.