NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page getting Refferer with Javascript

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-11-2005, 10:49 AM THREAD STARTER               #1 (permalink)
dre
NamePros Regular
Join Date: Jul 2005
Posts: 595
dre has a spectacular aura aboutdre has a spectacular aura about
 



getting Refferer with Javascript


hey, does anyone know how to get the refferer with javascript then pass it on to a php script for that to write to a text file? i got the php bit sorted i just need the java script bit to place in my .html to pass the vars to my php script

Code:
<!--
  stats = "referrer=" + escape(window.document.referrer);
  stats += "agent=" + escape(navigator.userAgent);
  document.write('button.php' + stats +'">');
//-->
dre is offline  
Old 09-11-2005, 11:10 AM   #2 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 71
lemmin is an unknown quantity at this point
 



how about the server variable $_SERVER('http_referer')

That's the server variable for asp. I don't do php, but I'm pretty sure it's the same.


By the way, I have never gotten that varible to return anything in asp, but if your Jscript is working, you can submit it to a php file through a form on load. Just use something like:

HTML Code:
<body onLoad="myForm.submit()">
<form id="myForm" action="refered.php" method="POST">
<input type=hidden value=referrer>
I'm sure there's an easier way, but that's what popped into my head
lemmin is offline  
Old 09-11-2005, 11:11 AM   #3 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



If the end result is PHP, why not get the referrer in PHP?

<?php
$ref= $_SERVER['HTTP_REFERER'];
?>

However, don't rely on it too much, since the referer is sent from teh client, it's not trustworthy.
__________________
OnlineGames.net
slantednet is offline  
Old 09-11-2005, 11:17 AM THREAD STARTER               #4 (permalink)
dre
NamePros Regular
Join Date: Jul 2005
Posts: 595
dre has a spectacular aura aboutdre has a spectacular aura about
 



i dnt want to use straight php, because i of to put in .tpl files, so if i get the details then pass it to a remote php script that then writes to a txt file, that possible?
dre is offline  
Old 09-11-2005, 12:23 PM   #5 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



What's wrong with your existing code (with a few mods)?

Code:
<!--
  stats = "?referrer=" + escape(window.document.referrer);
  stats += "&agent=" + escape(navigator.userAgent);
  document.write('button.php' + stats);
//-->
That should output "button.php?referrer=<referrer here>&agent=<agent here>" into the page where you have the script... no?
__________________
OnlineGames.net
slantednet is offline  
Old 09-11-2005, 12:33 PM THREAD STARTER               #6 (permalink)
dre
NamePros Regular
Join Date: Jul 2005
Posts: 595
dre has a spectacular aura aboutdre has a spectacular aura about
 



that code i post doesnt work
dre is offline  
Old 09-11-2005, 03:20 PM   #7 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 71
lemmin is an unknown quantity at this point
 



Originally Posted by dre
if i get the details then pass it to a remote php script that then writes to a txt file, that possible?
Did you see the code I posted? Because, that's what it does.
lemmin is offline  
Old 09-11-2005, 03:28 PM THREAD STARTER               #8 (permalink)
dre
NamePros Regular
Join Date: Jul 2005
Posts: 595
dre has a spectacular aura aboutdre has a spectacular aura about
 



im not using a FORM!
dre is offline  
Old 09-11-2005, 11:18 PM   #9 (permalink)
NamePros Member
Join Date: Sep 2005
Posts: 71
lemmin is an unknown quantity at this point
 



Why wouldn't you want to use a hidden form?
lemmin is offline  
Old 09-11-2005, 11:27 PM   #10 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



eh... tired of playing hide-and-seek with help-seekers, constantly guessing what the problem could be because of lack of working info, like errors, results, source, desired operation, desired output, what you've tried on your own, etc...

Diagnosing software and server issues is often difficult work without being able to see or understand the whole picture. It's funny how people want to give you just a tiny, half worn, and barely recognizable peice of a puzzle and ask for someone to describe the completed picture to them. Then, when someone takes time out of their day to attempt to help, the seeker dares to get short with the helper... eh, tough sh*t, figure it out yerself.. I originally wondered why few people dive in to help in various forums, especially the programming one, and now I see that they probably just gave up on ungrateful requestors...
????: NamePros.com http://www.namepros.com/programming/122798-getting-refferer-with-javascript.html

For future reference, here's a decent guide on how to ask a question:

How to ask questions the smart way

Particularly important would be the following sections:

Discuss your problem's symptoms, not your guesses

Discuss your problem's symtoms, in chronological order

Describe the goal, not the step

and

Courtesy never hurts, and sometimes helps

Good luck finding a solution,
Mike
__________________
OnlineGames.net
Last edited by slantednet; 09-11-2005 at 11:33 PM.
slantednet is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript / PHP Question Zubair1 Programming 4 08-20-2005 09:55 AM
looking someone that knows javascript REALLY well.... axilant Programming 3 04-29-2005 03:24 AM
Loading different images depending on the browser (JavaScript) Nevsan Programming 3 04-04-2004 10:36 AM
How do you detect resolution & launch an app with javascript? Rhino1616 Programming 14 12-04-2003 05:10 PM
Javascript Functions: Your needs. Mp)Tarh Web Design Discussion 1 11-15-2003 06:50 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:13 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger