Javascript 在<;a>;标记打开多次
我想知道如何在html链接打开耦合的URL 10次或更多次Javascript 在<;a>;标记打开多次,javascript,html,Javascript,Html,我想知道如何在html链接打开耦合的URL 10次或更多次 然而,我没有恶意。我只想恶作剧一个朋友。使用HTML,你只能打开一个带有a标签的链接;请查看JavaScript,然后window.open()(): var windowObjectReference=window.open(strUrl,strWindowName[,strWindowFeatures]) 例如: window.open('http://www.example.com'); //You maybe don't nee
然而,我没有恶意。我只想恶作剧一个朋友。使用HTML,你只能打开一个带有
a
标签的链接;请查看JavaScript,然后window.open()
():
var windowObjectReference=window.open(strUrl,strWindowName[,strWindowFeatures])
例如:
window.open('http://www.example.com'); //You maybe don't need to keep a
//reference of the newly opened window here
你需要多少时间就给这个打电话
不过要小心,它的行为就像一个弹出窗口,可能会被浏览器自动阻止(比如Chrome33)
行动中
您可以有如下链接:
<a href="http://www.goodjoke.com" id="prank_link">
这里有一个有没有一种方法可以只在HTML中完成?我不知道javascript是如何工作的。@TobyvanKempen不,你不能相信。不要害怕JS,首先检查一下。看我编辑的答案,我提供了一个JS用法的示例。
<script>
//When the document is "loaded", execute the following code
document.onload = function(){
//Get the a element, identified by its ID
var prank_link = document.querySelector('#prank_link');
prank_link.onclick = function(e){
e.preventDefault(); //Prevent the page to be changed
var my_url = this.href; //Store the url in the link
for(i = 0; i < 10; i++){ //Call window.open() 10 times with your URL
window.open(my_url);
}
}
}
</script>