开发者

Client side href lost, can I send it back on postback?

开发者 https://www.devze.com 2023-02-02 09:03 出处:网络
I\'m losing client side href. Is it possible to send it ba开发者_如何学JAVAck to the server on the button submit using a variable or something?Yes. You could use a hidden form input, added on either t

I'm losing client side href. Is it possible to send it ba开发者_如何学JAVAck to the server on the button submit using a variable or something?


Yes. You could use a hidden form input, added on either the server or client side:

<input type="hidden" name="referring_url" value="http://...">

To automatically add the current URL using JavaScript:

<form onsubmit="addHref(this)" ...

function addHref(form) {
    var input = document.createElement('input');
    input.type = 'hidden';
    input.name = 'referring_url';
    input.value = window.location.href;
    form.appendChild(input);
}
0

精彩评论

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

关注公众号