开发者

Autofill Text Field Value with Current Page URL

All I am looking to do is autofill a hidden text field with the current page URL, so that when the开发者_开发问答 user submits the form, I know the page they sent the form from. This will save me a ton of headaches dealing with inquiries.

In other words, when the page loads, I'd need the text field value to be value="http://www.example.com/"

Ideally, looking to accomplish this with just Javascript/HTML.

Any help would be much appreciated. Thanks!


Assuming you can give your hidden field an ID, put the following in your onload or document-ready processing:

document.getElementById("yourHiddenFieldId").value = window.location.href;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜