Ric*_*nop 4 html javascript jquery
我需要在具有特定尺寸的新窗口(NOT TAB)中打开某些链接.
这将在新标签中打开一个链接:
$(document).ready(function() {
$('a[rel|=external]').click(function(){
window.open(this.href);
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
要在新窗口中打开链接需要更改什么.
编辑:这是我的整个javascript文件:
$(document).ready(function() {
$('a[rel=external]').click(function(){
window.open(this.href);
return false;
});
$('a[rel=external-new-window]').click(function(){
window.open(this.href, "myWindowName", "width=800, height=600");
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
<a href="/clientarea/utils/law/id/2832" rel="external-new-window" class="accessible-link">§5, odsek 2</a>
Run Code Online (Sandbox Code Playgroud)
Nic*_*ver 20
您可以window.open()为此传递维度:
编辑更新的问题:请注意已[rel|=更改为[rel=.
$(document).ready(function() {
$('a[rel|=external]').click(function(){
window.open(this.href);
return false;
});
$('a[rel=external-new-window]').click(function(){
window.open(this.href, "myWindowName", "width=800, height=600");
return false;
});
});?
Run Code Online (Sandbox Code Playgroud)
你可以在这里测试它,尺寸与标签不同是这里的关键.请记住,它仍然可以在选项卡中打开,有很多浏览器选项,扩展和插件专门用于防止弹出窗口.
此外,从用户的角度来看,太多的弹出窗口会鼓励我追捕你并用沙拉叉刺伤你的眼睛和/或弹出窗户然后把它扔出去,所以请谨慎使用.