我卡在某个地方,我希望测试 1 和测试 2 链接在新窗口中弹出,不 target=_blank 进入新窗口,这样弹出窗口就不会出现' t 在 firefox 等中作为选项卡打开。javascript 中的 "href"
用于填充测试 1 和测试 2 链接中的 href #
。我做错了什么所以我也可以将弹出窗口打开到一个新窗口但不是作为目标 _blank?
<p><a id="test1" href="#">Test 1</a></p>
<p><a id="test2" href="#">Test 2</a></p>
<script>
if(chatlink_flag == 'true')
{
document.getElementById('test1')window.open.href('http://www.example.com/chat1/open.htm','window1','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
document.getElementById('test2')window.open.href('http://www.example.com/chat2/open.htm','window2','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}else{
document.getElementById('test1')window.open.href('http://www.example.com/chat1/closed.htm','window1','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
document.getElementById('test2')window.open.href('http://www.example.com/chat2/closed.htm','window2','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}
</script>
最佳答案
除了缺少“javascript:”部分外,您的代码似乎还不错。
因此您可以尝试像这样执行 window.open 行:
document.getElementById('test1').href = "javascript:window.open('http://www.yourpage.com/', 'window1', 'scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no')";
关于javascript - Window.open + href 替换并弹出到新窗口但不使用目标_blank,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5986007/