日期:2014-05-16 浏览次数:20395 次
<!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=gb2312" />
<title>用js批量处理a标签的target属性_blank</title>
</head>
<body>
<DIV id="main"><a xxx="123456" xyz="54321" href="test_js.html">1</a></DIV>
<a href="test_js.html">2</a>
<script language="javascript">
var anchors = document.getElementById("main").getElementsByTagName("a");
for(i=0;i<anchors.length;i++){
var anchor_item = anchors[i];
anchor_item.target="_blank";
}
</script>
</body>
</html>