dreamweaver工具,在替换那里自己写了一个正则,批量匹配后,果然不让我失望!感叹正则的强大啊!正则规则如下
- <!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>
- <a href="http://sc.vevb.com">正常链接测试</a>
- <div id="test">
- <a href="http://sc.vevb.com">被JS处理过的链接测试</a>
- </div>
- <script language="JavaScript">
- var anchors = document.getElementById("test").getElementsByTagName("a");
- for(i=0;i<anchors.length;i++){
- var anchor_item = anchors[i];
- anchor_item.target="_blank";
- }
- </script>
- </body>
- </html>
新闻热点
疑难解答