[英]Window.open() not working + how to close a tab
I am trying to make it so when someone goes onto my codepen --> https://codepen.io/Mike-was-here123/pen/gXMrJO , the window opens itself. 我正在尝试这样做,以便当有人进入我的Codepen-> https://codepen.io/Mike-was-here123/pen/gXMrJO时 ,窗口会自动打开。 Basically a infinite loops opening and closing itself, this is my JS/ jQuery code: 基本上是一个无限循环来打开和关闭自身,这是我的JS / jQuery代码:
I added comments in the code on the codepen. 我在代码笔上的代码中添加了注释。
$(document).ready(function() {
if (document.URL !== "https://codepen.io/Mike-was-here123/full/ooLxmQ/") {
window.open("https://codepen.io/Mike-was-here123/full/ooLxmQ/");
}
var one = 1;
if (1 === 1) {
window.open("https://codepen.io/Mike-was-here123/full/ooLxmQ/");
one += 1;
}
if (one !== 1) {
window.close();
}
});
Why doesn't the window open? 为什么窗口没有打开?
Also if i wanted to close the current tab because i just opened a new one, would i just use window.close()
? 另外,如果因为刚打开一个新标签而要关闭当前标签,我会只使用window.close()
吗?
If you want to open an infinite number of web pages, just do this: 如果要打开无限数量的网页,请执行以下操作:
while (true) {
window.open("insert web page");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.