[英]Html opening multiple links on the page in a same new window
We have a html page which has approxi 10 links on it. 我们有一个html页面,上面有大约10个链接。
There should be only at the max two browser windows open on the user's computer. 用户计算机上最多只能打开两个浏览器窗口。
I have tried with the following two ways and it did not work. 我尝试了以下两种方法,但没有成功。 The every click on the link has opened a new broswer window.
每次单击链接都会打开一个新的浏览窗口。 That means after clicking all ten links I had 11 browser windows open.
这意味着单击所有十个链接后,我打开了11个浏览器窗口。 Here are the two basic ways which I have tried.
这是我尝试过的两种基本方法。
i) 一世)
<a href="http://www.google.com" target="infoWindow">
link1
</a>
ii) ii)
<a href="#" onclick="window.open('http://www.google.com', 'infoWindow', 'width=300, height=250'); return false;">info1</a>
Can somebody suggest a solution? 有人可以提出解决方案吗?
I see you are calling your window by the same name and yet they are still opening in a new window, it could be because your onclick function hasn't get specific scope to save the reference to the window. 我看到您正在使用相同的名称调用窗口,但它们仍在新窗口中打开,这可能是因为您的onclick函数没有获得特定范围来保存对窗口的引用。
If you were to change onclick to a function you can cache the window. 如果要将onclick更改为功能,则可以缓存窗口。
//js
var myWindow;
function myClick(){
myWindow = window.open("http://www.google.com", "infoWindow", "width=300, height=250");
return false;
}
//html
<a href="#" onclick="myClick()">info1</a>
Great article here : infimum.dk 伟大的文章在这里: infimum.dk
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.