Link to home
Start Free TrialLog in
Avatar of Snehal Rana
Snehal RanaFlag for United States of America

asked on

Create an Exit link which returns users to referring page

We are using SharePoint 2007. The users come to my site from a link setup on another site. I need to create an Exit link on the header of my main Site collection. When user clicks on this Exit link they should be send to the site or page they came from.
Avatar of chapmanjw
chapmanjw
Flag of United States of America image

Here is how I would accomplish this using JavaScript:

1) Get the referring URL (document.referrer)

2) Set a cookie with the the referring URL (here is info on how to set a cookie in JavaScript: http://www.quirksmode.org/js/cookies.html)

3) Create a function that enables the Exit link if a referring URL cookie is set

4) Set the link to call a JavaScript function that reads the cookie and redirects the user to the referred page.

Ill write up a tutorial for this, but just wanted to put this out there so that you had somewhere to start in the meantime.
ASKER CERTIFIED SOLUTION
Avatar of chapmanjw
chapmanjw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Snehal Rana

ASKER

I am testing this out as I write. Appreciate quick response.
Hi Chapmanjw,

I tried inserting this code on default.aspx and it errors out as below:
" '$' is undefined"

Let me know
Excellent solution by chapmanjw. Got this working with little tweak. I needed to place both the js files in appropriate location and it worked like a charm.
Thanks a bunch