Forum Moderators: open
1) the link is clicked (most of these are target="_blank" and the onUnload does NOT run as far as I know.)
2) a script runs somehow that checks the URL and domain name and if the link is an external domain name it runs the pop up function.
3) the user can then click CONTINUE or CANCEL.
4) IF they click CONTINUE Then the URL that was determined from the previous funtion somehow loads into a new window. If they click Cancel the window just closes and the old site is still in the background.
i have seen sites that use onClick on every link that leaves the site but there must be a way to do this dynamically where I don't have to put this command on every link I hope!?
(ASP creates this popup dynamically and the URL is passed as an attribute on the end of the link to the ASP page. )
<table cellspacing="0" width="150">
<tr>
<td><a href="http://www.external_link_URL.com" onclick=" window.close();" target="_blank"><img src="images/btn_continue.gif" width="67" height="15" alt="" border="0"></a></td>
<td><a href="javascript:window.close();"><img src="images/btn_cancel.gif" width="67" height="15" alt="" border="0"></a></td>
</tr>
</table>
Thanks!
VC
It is hard to imagine how JavaScript could trap the click event without an onclick or onmousedown event handler in the anchor tag.
As links are executed locally, I don't think there is anything server side that would be of use, either.
How about something like this:
<script type="text/javascript">
<!--
function click(e){
//if IE
if(typeof event!='undefined'){
//if the object clicked on has an href
if(event.srcElement.href){
alert(event.srcElement.href)
}
//else assume w3 standard (ns6+, mozilla)
}else{
//if the object clicked on has an href
if(e.target.href){
alert(e.target.href)
}
}
}
//global click handling
document.onclick=click
//-->
</script>
Just add some code to determine whether or not the link is local and you should be set. BTW, this code does not work in old browsers like ns4, but there is an event model for that as well--just not included here.
Hope this helps,
ajkimoto