user663724
user663724

Reputation:

window.open is not opening a new window when used with parameters

On clicking of the HyperLink , i am calling the below function

window.open("<%=forHyperLink%>",'name','height=600,width=800');

The issue is that , with the above line , only one time Hyper Link click is working (That is if another hyper link is clicked , no window is being opened up)

But if i remove the parameters for window.open and simply use

window.open("<%=forHyperLink%>");

Then on click of every Hyperlink a new window is being opened.

Please adivce .

Upvotes: 2

Views: 7861

Answers (2)

tradyblix
tradyblix

Reputation: 7569

Change the name of each window per link so the window opened on initial click won't be re-used.

I'm guessing that clicking on other links opens the links on the initial/currently opened pop-up and causes confusion that it doesn't open new windows.

// first window to open
window.open("first.html",'name','height=600,width=800');

// opens in the same window where first.html is opened because 
// it targets the same window called `name`
window.open("second.html",'name','height=600,width=800');

// this works because by default it will open a new one everytime it is executed
window.open("new.html");

// opens a window with unique name 
window.open("<%=forHyperLink%>",'name_' + Math.random(),'height=600,width=800');

Upvotes: 9

Jason
Jason

Reputation: 57

You can use window.open("<%=forHyperLink%>",'name_'+(new Date()).getTime(),'height=600,width=800');

'name_'+(new Date()).getTime() will be changed at each window opened

oNewWindow = window.open( [sURL] [, sName] [, sFeatures] [, bReplace])

Please find the detail of window.open from the following link

http://msdn.microsoft.com/en-us/library/ms536651(v=vs.85).aspx

Upvotes: 0

Related Questions