我需要能够设置,在JavaScript中,所有的HTML页面链接到新标签中打开,我该怎么办呢?JavaScript打开一个新标签的所有HTML链接?
是否可以归结到div“链接”?
这里是我的代码:如果没有在HTML中使用target属性
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Negócios</title>
<script type="text/javascript">
</script>
</head>
<body>
<div id="links">
<p><a href="https://www.facebook.com/groups/ivendi.maringa2/" data-hovercard="/ajax/hovercard/group.php?id=472352436193468" aria-owns="js_1j" aria-haspopup="true" id="js_1k">MARINGÁ - NEGÓCIOS</a></p>
<p><a href="https://www.facebook.com/groups/638497612850047/" data-hovercard="/ajax/hovercard/group.php?id=638497612850047" aria-owns="js_1l" aria-haspopup="true" id="js_1m">MONTES CLAROS - NEGÓCIOS</a><br>
</p>
<p><a href="https://www.facebook.com/groups/aggape/" data-hovercard="/ajax/hovercard/group.php?id=538358279511007" aria-owns="js_1r" aria-haspopup="true" id="js_1s">Sucesso Empresarial</a></p>
</div>
</body>
</html>
我需要做的。我有太多的链接,我也想学习如何做到这一点。
通过使用目标属性? – epascarello 2014-11-24 16:52:13
只给一个元素一个'target =“_ blank”' – twain 2014-11-24 16:52:28
为什么你需要用Javascript做到这一点?为什么不将target属性设置为_blank? 'My Line' – Robbert 2014-11-24 16:52:33