Discussion Locked

Javascript to Inform of redirection

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to ensure that on my external links page, when links are clicked, the user is informed that they are now leaving my site and then are redirected to the outside site. I would prefer to use javascript or something else that does not require the server. But I cannot figure out how to do this simply using javascript. Likewise, I need the code to not reside in the link because new links will be added by nontech people and it should be as simple as possible for them to add new links. Any suggestions?

7 replies

by ebob

You have to put something in the link, like the destination URL, and perhaps a comment specific to this redirection. I think you want something along the lines of (the details may need to be fine-tuned):

then in the HTML:

Go Away - Over there

Your content manager(s) need to build the link from a "cookie cutter" template, substituting the destination URL, specific comment, and the text in the link. The JS function does the rest.

by lynnmoon

Thanks, but this is what I currently have and they don't really want the onClick in the link. I need something that does not touch my links at all if possible.

by magicdress

use events on your body tag, ie:

or 'onbeforeunload'. your own popup (window.open method) would be nicer to see than an alert box tho...

hth,
becky

by lynnmoon

Thanks Becky. I think that I like this. By the way, you don't happen to know rather or not there is an if statement that I can write to indicate that if they hit the back button nothing happens, do you?

This discussion is closed to new replies.