javascript 在javascript中隐藏url参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21580647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hide url parameters in javascript
提问by Andrew Simpson
I am using this:
我正在使用这个:
document.location ='my different asp.net page?=myparams'
Is there a way to hide the values of the params in the URL displayed on the browser?
有没有办法隐藏浏览器上显示的 URL 中的参数值?
I know I could use hidden Form values and I know I can encrypt the values (which is what I will do if no joy here).
我知道我可以使用隐藏的 Form 值,我知道我可以加密这些值(如果这里没有乐趣,我会这样做)。
Is there a simpler tidier way of doing this? Perhaps via JQuery.
有没有更简单更整洁的方法来做到这一点?也许通过 JQuery。
回答by iii
回答by HieuHT
One solution is to set document.location to a second page, that page keep param values in a session variable and redirect to your desired one.
一种解决方案是将 document.location 设置为第二页,该页将 param 值保留在会话变量中并重定向到您想要的。
document.location = "redirectpage.php?param=value"
document.location = "redirectpage.php?param=value"
In redirectpage.php
在redirectpage.php
$_SESSION['param']=$_GET['param]; header('Location: ' . desired_page?param=value);
$_SESSION['param']=$_GET['param]; 标头('位置:' .desired_page?param=value);
By this way, value of param will be only displayed in a very short time when redirectpage.php redirecting to desired page.
这样,param 的值只会在redirectpage.php 重定向到所需页面时很短的时间内显示出来。
Hope it helps
希望能帮助到你
Btw, can you explain how hidden Form works in this case?
顺便说一句,你能解释一下隐藏表单在这种情况下是如何工作的吗?