...

View Full Version : Automatically Retrieve <title> of Referring Page



Pennimus
09-01-2006, 02:25 AM
Hi all,

Title of the thread says it all really - I'm not even sure whether to be looking for a JS or PHP solution (my instinct is JS). Anyone have any ideas?

Regards

mlseim
09-01-2006, 02:34 AM
So I assume you already are able to see what the referring page is?
You just want to grab the title?

Or, are you thinking about opening a log file and reading in the referring
URLs ...

I'm not sure how you are seeing the referral URLs to begin with.

Pennimus
09-01-2006, 02:49 AM
Sorry, the referring URL is in the query string. I'm creating a bookmarking system where you have a button on your toolbar with this JS function:


javascript:location.href='http://www.example.com/bookmark.php?url='+encodeURIComponent(location.href)"

If you know del.icio.us, it's basically that kind of deal.

EDIT: I've just realised I can probably encode the title at the same time as the URL. Doh! *potters off to try that out*
EDIT: It works, kind of...

These two functions work seperately to get the two bits of information I need:


+encodeURIComponent(location.href)

+encodeURIComponent(document.title)

However, I'm not sure how to combine them to get the query string I need, which would look something like ?url=[referring url]&title=[referring title]. It's the apostrophes seperating up the link and the encodeURI functions that are playing up. Having tried the obvious (JS in red for clarity)...


javascript:location.href='http://www.example.com/bookmark.php?url='+encodeURIComponent(location.href)'&title='+encodeURIComponent(document.title)"

... I've come to the end of my javascript expertise :-D Anybody know how to toggle these two last bits together properly?

felgall
09-01-2006, 04:06 AM
You left out the + in href)+'&title



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum