我有这个广泛依赖于 Request.UrlReferrer
的应用程序用于处理链接点击并维护用户在应用程序中所处位置的页面历史记录。
要求已更改,我现在需要使用 <input type="button" />
在特定位置导航而不是 <a href="mypage.aspx"/>
目前我正在尝试
<input type="button"
onclick='ShowLoadingScreen();document.write("<a id=\"link\" style=\"display:none;\" href=\"mypage.aspx\">link</a>");document.getElementById("link").click();'>
Do Thing
</input>
但代码并不像我希望的那样干净,并且写入文档会破坏我的加载屏幕。如果我在页面上设置了某些内容的 innerHTML,我的点击将停止工作。
Clients can falsify or choose not to present a Referer header. Therefore, while the UrlReferrer property can be useful for identifying basic trends in Web traffic; you should not use it as part of an authorization scheme to control access to data.
因此可以伪造它,这对我的目的来说非常有用。但是我不知道如何实现这一目标。
有没有一种方法可以使用 javascript 来伪造 UrlReferrer,这样我就可以将我的代码保持在最低限度? 有点像
<input type="button"
onclick='ShowLoadingScreen(); SetUrlReferrer(); window.location="mypage.aspx";'>
Do Thing
</input>
不幸的是,这不起作用。
document.referrer = 'myref.aspx';
Error: Object doesn't support this action
最佳答案
对不起,我认为它不会奏效。这只有在您手动构建 http 请求时才有可能(即使使用 ajax,您也会在大多数浏览器上遇到问题)
关于javascript - 是否可以在客户端 javascript 中设置 Request.UrlReferrer?如果是这样,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6834111/