Bookmarklet that goes to a url and makes the referring url available as a variable for a script.
June 12, 2005 10:13 PM Subscribe
I need a bookmarklet that goes to a specified (static) url and makes the url of the page I came from available as a variable for a perl or php script. I just want to be able to go to a page I've set up and have it record the page I'm got there from, but the apparently-useful-for-just-this-sort-of-thing http_referrer variable only works if i clicked on a link to get there, while I, in my hubris, would like to be able to type the address in manually from anywhere. But apparently I can't. So it looks like a bookmarklet is the next best thing.
The thing is, I've spent alot of time learning php and perl to get to the point that I even know enough to need this, but bookmarklets are javascript, and javascript is a nut that is resisting my efforts to crack. I'm working on learning this crazy new language cause I'd like to be able to function in it, but maybe someone here can throw me a line on this one in the mean time? Because really I'd rather be learning more perl right now and it seems like this would be mad simple if you know the stuff. For me its agony.
The thing is, I've spent alot of time learning php and perl to get to the point that I even know enough to need this, but bookmarklets are javascript, and javascript is a nut that is resisting my efforts to crack. I'm working on learning this crazy new language cause I'd like to be able to function in it, but maybe someone here can throw me a line on this one in the mean time? Because really I'd rather be learning more perl right now and it seems like this would be mad simple if you know the stuff. For me its agony.
And drunk... replace 'http://www.mydomain.com/mypage.html' with your static page. Not 'http://www.cnn.com/'. I just like CNN.
posted by Turd Ferguson at 10:37 PM on June 12, 2005
posted by Turd Ferguson at 10:37 PM on June 12, 2005
Best answer: This works (assuming I correctly understand your question):
posted by bricoleur at 4:35 AM on June 13, 2005
a href="javascript:location.href='http://yourdomain.com/yourpage.php?TITLE='+document.title+'&LOCATION='+escape(location.href)"And thank you for introducing me to the world of bookmarklets! I cadged this off this page.
posted by bricoleur at 4:35 AM on June 13, 2005
Response by poster: Thanks! I ended up using
posted by 31d1 at 8:20 AM on June 13, 2005
a href="javascript:location.href='http://mysite.com?'+escape(location.href)"
. Simple, and it works perfectly!posted by 31d1 at 8:20 AM on June 13, 2005
Response by poster: And thanks Turd Ferguson, for while I didn't use your script per se, the way you wrote it out totally gave me an "aha" moment with all that variable assigning. You have taught a man to fish.
posted by 31d1 at 8:24 AM on June 13, 2005
posted by 31d1 at 8:24 AM on June 13, 2005
This thread is closed to new comments.
Of course, replace 'http://www.cnn.com/' with whatever static page you want. The location of the page you are coming from will be available as $_GET['ref'] in PHP, or similar in perl.
(Not tested, off the top of my head, etc...)
posted by Turd Ferguson at 10:36 PM on June 12, 2005