Reputation: 6797
How to add an onload
function to an opened window? (target is "self", not window.open
, just a regular link)
Is it possible with onbeforeunload
or something? Or add onclick
to the "normal link"?
I mean like this:
<a href="page2.htm" onclick="theWindowIHaveOpened.onload = function(){alert('loaded')}">...
Upvotes: 0
Views: 7266
Reputation: 1170
With an onclick handler on the link and an external chunk of script, you could do something like:
<script type="text/javascript">
function loadHandler()
{
// do stuff
}
function clickHandler(elem)
{
h = window.open();
h.onload = loadHandler;
h.location.href = elem.getAttribute('href');
return false;
}
</script>
<a href="page2.htm" onclick="return clickHandler(this);">Linky</a>
Though of course you may need to do some work with that to get it working cross-browser.
Edit Added the return
statements so that normal navigation of the <a>
tag is suppressed.
Upvotes: 0
Reputation: 207501
No, you will have no control over the next page with a basic http call of a link.
Upvotes: 1