Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with document.referrer

Status
Not open for further replies.

mrDrive

MIS
Aug 29, 2002
94
US
Hi,

I'm trying to figure out where the user has navigated from. I have a popup window with a link. When the user clicks on the link the popup window closes and the parent window navigates to url.html:

<a href=&quot;#&quot; onclick=&quot;opener.location.href='url.html'; window.close(); return false;&quot;>Click Me!</a>

Then in 'url.html', I want to print a link if the user came from the popup window. If they didn't come from the popup window link then it would print nothing:

if(document.referrer==&quot; {
document.write('<p><a href=&quot;url1.html>Go back to here</a></p>');
} else {}

Does anyone know a way to do this? Any help would be greatly appreciated!

Cheers!

mD
 
From :
Code:
<script language=&quot;Javascript&quot;>
<!-- 
// please keep these lines on when you copy the source
// made by: Nicolas - [URL unfurl="true"]http://www.javascript-page.com[/URL]

if (document.referrer&&document.referrer!=&quot;&quot;)
  document.write('Thanks for visiting this site from '+document.referrer+'<BR>');

//-->
</script>

Modifying this slightly:
Code:
<script language=&quot;Javascript&quot;>
<!-- 
// please keep these lines on when you copy the source
// made by: Nicolas - [URL unfurl="true"]http://www.javascript-page.com[/URL]

if (document.referrer&&document.referrer!=&quot;&quot;)
  if(document.referrer != '[URL unfurl="true"]http://www.mydomain.net/url.html'){[/URL]
    //Print Nothing
  }
  document.write('<p><a href=&quot;url1.html&quot;>Go back to here</a></p>');
}

//-->
</script>

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top