Forum Moderators: coopster

Message Too Old, No Replies

Capture current URL, display on new Popup

         

chessmotifs

5:07 am on Jul 4, 2007 (gmt 0)

10+ Year Member



Hi, :)

I'm new to WW forum and hope someone can advise me on a PhP or javascript coding. I am using PhP and MySQL. Here goes...

My intention:
1. In my "example.html" I want to create a link that when clicked, will popup a small browser window (200x200). (For this link, I want it dynamically usable in any webpage. Eg on a sidebar.)
2. In this new popup window, I want to capture and display the URL of the original referer page. For this case it's "http://....example.html".
3. Also in the new window is an option button which says "Save this URL? Yes/No". If user clicks "Yes" it saves the URL into the database.

It is sort of a tool to help users bookmark URLs of my website.

For 1, I have tried using javascript to do the sized popup (using onclick(window.open) ) ....which works, but unable to grab the intended URL onto the new page.
For 2, I can use the default HTML's target="_blank" combined with getenv("HTTP_REFERER") to get the previous URL, but then I cannot make the window size 200x200
How do I fulfill 1 & 2 at the same time?
Fo 3, I guess if I could find a solution to 1 & 2, it will be solved.

Hope someone could help me. Any advise is much appreciated.
Thanks! :)

Habtom

6:58 am on Jul 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you put your popup file as .php, say popup.php, You can do the following to get the previous URL:

$previous = getenv('HTTP_REFERER');

Hab

chessmotifs

7:12 am on Jul 4, 2007 (gmt 0)

10+ Year Member



Hi Habtom,
Thanks for your suggestion which I think I had also tried before, but does not work.

The getenv('HTTP_REFERER') returns blank because the javascript "onClick(window.open...)" launches a totally new window which doesn't have a history for genenv to retrieve.

Habtom

9:34 am on Jul 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onClick(window.open...)"

On this one pass the parameter.

the link you open goes as:

new_window.php?previous_link=$_REQUEST['PHP_SELF']

and that html page should go dynamic too

Hab

chessmotifs

10:01 am on Jul 4, 2007 (gmt 0)

10+ Year Member



Thanks for the suggestion! Will give it a try today.