最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.open is not opening a new window when used with parameters - Stack Overflow

programmeradmin4浏览0评论

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 .

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 .

Share Improve this question edited Apr 29, 2011 at 5:49 Sai Kalyan Kumar Akshinthala 11.8k8 gold badges45 silver badges68 bronze badges asked Apr 29, 2011 at 5:37 user663724user663724 1
  • Please show HOW you call this code. If you have onclick="window.open(" then the quotes are wrong. If you reuse the "name" which is not a good name for a window, it may go behind. try '_blank' instead – mplungjan Commented Apr 29, 2011 at 5:39
Add a ment  | 

2 Answers 2

Reset to default 9

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');

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./en-us/library/ms536651(v=vs.85).aspx

发布评论

评论列表(0)

  1. 暂无评论