简体   繁体   中英

Pass previous url through url string query to text field on next page

I have read some posts on here but I am trying to achieve something that I cannot seem to find.

I want to grab the Page A url that the user is on, once the user clicks on a button, it grabs that current Page A url, places it in the url, then passes it to a text field on the next page (Page B).

I know how text fields work with string queries such as /?textfield="Thisisatext"

Then it would output as "Thisisatext" inside the text field.

I am trying to achieve this without using Javascript. or any other alternatives.

If the URL is dynamic, it is not possible to pass it through url without Javascript. If it is a static url, you can simple do

<a href="urlToGo.com/olderurl="oldURL"/>

if it is dynamic url, then you need to get it with javascript, and mount the url to redirect to. Something like:

var url = document.URL;
var a = document.getElementById('yourlinkId'); 
a.href = "newurl.com/" + "oldurl=""" + url + """

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM