JavaScript and client side scripting.
Moderator: General Moderators
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon May 29, 2006 12:53 pm
phppage wrote: Thanks for that, will give it a go and let you know
I'd stick it in a function that runs onload in the body. If you put it in the head just like that it won't work because "document" isn't finished loading.
It'll almost certainly need some fixing.
phppage
Forum Contributor
Posts: 126 Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK
Post
by phppage » Mon May 29, 2006 1:08 pm
It only seems to work in Netscape, not IE. Is captureEvent valid in IE do you know?
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon May 29, 2006 1:12 pm
Oops sorry typo there - it's captureEvents().
phppage
Forum Contributor
Posts: 126 Joined: Mon Apr 24, 2006 1:47 pm
Location: West Yorkshire, UK
Post
by phppage » Mon May 29, 2006 1:40 pm
You are a star, got it to work with very little tweaking. Here is the final code
Code: Select all
<script language="Javascript" type="text/javascript">
function nullEvent()
{
window.onunload = null;
}
function correctlinks() {
var links = document.getElementsByTagName('a');
for (var i in links)
{
if (links[i].captureEvents) links[i].captureEvents(CLICK);
links[i].onclick = nullEvent;
}
}
</script>
</head><body onunload="window.opener.focus();" onload="correctlinks();" >
Thanks for your help.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon May 29, 2006 1:44 pm
Glad you got it working