| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Jul 2005
Posts: 595
![]() ![]() | 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 +'">');
//--> |
| |
| | #2 (permalink) |
| NamePros Member Join Date: Sep 2005
Posts: 71
![]() | 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> |
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | 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 |
| |
| | #5 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | 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);
//-->
__________________ OnlineGames.net |
| |
| | #10 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | 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.
|
| |
![]() |
| 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 |