简体   繁体   中英

Insert text into a textarea on a different page

Just wondering if anyone can help me. I'm building a refreshed version of a website and the old designer has put a feature on the website where when the user clicks on one of the icons it takes them to the contact page but also fills in the textarea on the contact form with the title of the link.

I was just wondering if anyone knew how to do this. This is not a duplicate question as I am asking how to do this across 2 pages.

Thanks

You can use in javascript

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}

then get text like

var textfromURL= getURLParameter('content');

and set that "textfromURL" in your text box

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