我希望有一个在单击时打开弹出窗口的链接,但是如果用户没有启用 JS,我希望它在新窗口中打开一个页面。
以下似乎不起作用,
<a id="tac-link" target="_blank" href="tac.html">terms and conditions</a>
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=600,left = 445,top = 150');");
}
$('tac-link').click(function() {
popUp('tac.html');
return false;
});
我认为你只是把 id 选择器弄错了。尝试改变$('tac-link')
to $('#tac-link')
.
另一种方法:
$('a[target="_blank"]').click(function(e) {
window.open( this.href );
e.preventDefault();
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)