|
-
Nov 22nd, 2008, 06:12 PM
#1
Thread Starter
Addicted Member
Javascript Close Event.
I have a frame called viewer.
When a herf link if pressed within the frame i would like to check to see if the link they have pressed is a internal link, I.E. is it a link to another part of my site or if another site is going to load within the frame.
I am trying to use the a onClose event to excute javascript to check this. and if it is a extranel link, stop the unload and open up the link in a new window. I have try using PHP to parse the pages and add target="_blank" but because all these pages have been programmed by different people no one uses a standard <a> so a regular expression can't be created so it works all the <a> tags.
so far i have,
just need to know a var that contains the new url that the page is going to change to.
<script>
var cmpto = top.document.location;
cmpto = cmpto.substring(0, cmpto.indexOf("/", 7));
var newloc = ????;
newloc = newloc.substring(0, cmpto.indexof("/", 7));
if (cmpto == newloc) {
// extranel link.
window.open(newloc);
return false;
}else {
// do nothing
return true;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|