lundi 29 juin 2015

Copying a URL of page X to a readonly text field on page Y


From a webpage www.foo.com, a user clicks a feedback hyperlink to submit feedback about something. It opens a new page with text fields to fill out. What I would like to do is get the URL of the original page www.foo.com for example, to appear in a readonly field on the new page.

This is what I currently have as my test code on my feedback page.

<input id="URL" type="text" name="pageURL" readonly> <script type="text/javascript"> document.getElementById('URL').value = document.location.href; </script>

This displays the URL of the feedback page, page Y, which is what I would expect.

But I'm drawing a blank on how I would get the url of page X, in this example, www.foo.com to appear in the readonly.

I would assume I have to do something in the code for the original page and have that carry over. I do have CORS functioning for other purposes but the information I'm using for that is being brought to a php file instead of the .htm file the form page operates on. I'm still a beginner with CORS but I wouldn't think something like a URL would require it. Or maybe this is mindblowingly simple.


Aucun commentaire:

Enregistrer un commentaire