开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜