|
Re: Need to open ALL links in new window
Sorry for the previous post. I should have tested the code first. It turns out that document.onload needs to be changed to just onload. I have posted my test pages below.
- Code: Select all
//test.htm
<html>
<head>
<script>
onload = function() {
var frame = parent.frames[0].document;
var links = frame.getElementsByTagName('a');
for (var i=0; i<links.length; ++i) {
links[i].setAttribute('target','_blank');
}
}
</script>
</head>
<body>
<iframe src="test2.htm" width="200" height="100"></iframe>
</body>
</html>
- Code: Select all
//test2.htm
<html>
<head>
</head>
<body>
<a href="test.htm">one</a><br><br>
<a href="test.htm">two</a><br><br>
<a href="test.htm">three</a>
</body>
</html>
Last edited by jtek; Jul 31st, 2006 at 16:21.
|