Situation:
A user is viewing a web-page using the contact option provided. Upon clicking ‘Contact’, I’d like to pass the URL of the currently viewed page as text into a field of that contact form.
The starting point is any HTML page (page-xy.html).
The existing contact-form is written in PHP, HTML and CSS (contact.php) and does function fine.
I assume a Javascript may help to accomplish this procedure.
Upon clicking the ‘Contact’ button, this Javascript command reads the current URL:
var strReferrer=window.location.href;
The question is how to pass this variable ‘strReferrer’ on to ‘contact.php’ that is being opened?
In the following the variable should be inserted into the message text field for example.
I’d rather not use a cookie for this.
Hope someone has suggestions leading to the solution, thanks.
My goal is just about the reverse of the problem described in this thread
Here is the solution that I have implemented.
In any HTML page with a contact option, call a simple script as stated below.
In case JS is not available the contact form opens via ‘href’ and of course without the originating URL.
… that puts the string of the current URL into ‘strReferrer’ and opens a new window with your contact-form.php
PHP queries the string with ‘strReferrer’ and keeps it in ‘$params’.
in contact-form.php:
Now you know the page-url your visitors have decided to contact you.