日期:2014-05-16 浏览次数:20418 次
window.onload = function() { var frames = document.getElementById("frame-main"); var doc = frames.contentWindow.document; if (!doc.getElementsByTagName) return; var anchors = doc.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href")) anchor.target = "_self"; } };
<div id="bg-wrapper"> <iframe src="../../2010/Default.aspx" name="frame-main" id="frame-main" frameborder="0" height="100%" scrolling="auto" width="100%"></iframe> </div>
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <iframe src="2.html" frameborder="1" onload="fn(this)"></iframe> <script type="text/javascript"> var fn = function(t){ var doc = t.contentWindow.document; var anchors = doc.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; console.log(1) if (anchor.getAttribute("href")) anchor.target = "_self"; } } </script> </body> </html>