[英]When adding “target”: “blank” to links via javascript, opened tab is “recycled” (reused) - any way to prevent?
At least in safari, all links with the target added dynamically, will open in the same tab. 至少在safari中,动态添加了目标的所有链接都将在同一标签中打开。 I would like all links to open in new tabs, as is the default behavior when the target is specified in HTML (statically).
我希望在新标签页中打开所有链接,这是在HTML(静态)中指定目标时的默认行为。
Is there a workaround? 有解决方法吗?
<html>
<body>
<script type='text/javascript' charset='utf-8' src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$('a').attr({'target': 'blank'});
});
</script>
<a href="http://www.google.com">google</a> - <a href="http://www.yahoo.com">yahoo</a>
</body>
</html>
blank
is an arbitrary window name. blank
是任意的窗口名称。
You mean _blank
. 你的意思是
_blank
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.