正如我在长时间RND后告诉我的,我点击了解决方案,我只是用代码阐述了这些事情。
当用document.location.href或window.open打开一个新窗口,然后在IE8或更低版本中,Request.UrlReferrer为空,它不在IE9或Firefox或Chrome中。
的解决方案是
你在哪里都一样使用 document.location.href = “/角色/索引”;
只需将下面的函数复制并粘贴到js文件中并调用该函数即可。
RedirectURL(“/ Roles/Index”);
function RedirectURL(url) {
var a = document.createElement("a");
if (a.click) {
// HTML5 browsers and IE support click() on , early FF does not.
a.setAttribute("href", url);
a.style.display = "none";
document.body.appendChild(a);
a.click();
} else {
// Early FF can, however, use this usual method
// where IE cannot with secure links.
window.location.href = url;
}
}
希望上述解决方案能解决问题。
页面上有一些“单击此处”按钮。点击按钮后,新选项卡中会打开一个新的URL页面。在打开页面时,我使用Request.UrlReferrer将Page的url存储在数据库中。 –
然后只需在新页面的URL中添加一个参数,如'&from = pageX'。它与引用者一样不可靠(因为用户可以更改它),但至少可以控制它被发送而不管浏览器配置如何 – CodeCaster
如果我无法传递任何参数,该怎么办?什么可以是另一种方式? –