javascript 不显示:要再次显示网页,Internet Explorer 需要重新发送您之前提交的信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7029966/
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
Do Not Display: To display the webpage again internet explorer needs to resend the information you've previously submitted
提问by Troy Mitchel
I would like not to dispaly the pop-up message below when post back occurs. My page has nothing to do with pricing it is displaying ms chart that updates on postback. How to disable in code or java script?
当回发发生时,我不想显示下面的弹出消息。我的页面与定价无关,它显示的是在回发时更新的 ms 图表。如何在代码或 java 脚本中禁用?
to display the webpage again internet explorer needs to resend the information you've previously submitted.
再次显示网页 Internet Explorer 需要重新发送您之前提交的信息。
This is the javascript i've tried: doesn't work though.
这是我尝试过的 javascript:虽然不起作用。
<script type="text/javascript">
// <!--
function submitForm() {
window.opener.document.forms[0].submit();
}
// -->
</script>
and is attached the function to the form as so:
并将函数附加到表单中,如下所示:
<body>
<form id="form1" runat="server" onsubmit="submitForm()">
回答by Aaron Adams
I'd bet you're doing this in your JavaScript:
我敢打赌你是在 JavaScript 中这样做的:
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
While the above code comes from the Facebook documentation, and it works for a standalone website implementing the Facebook JavaScript SDK, it will break your Facebook Appin Internet Explorer and Firefox by causing an infinite loop.
虽然上述代码来自 Facebook 文档,并且它适用于实现 Facebook JavaScript SDK 的独立网站,但它会导致无限循环破坏Internet Explorer 和 Firefox 中的Facebook 应用程序。
When Facebook loads an App, it sends information about the user's authentication state via POST. The SDK processes this data and authenticates the user.
当 Facebook 加载应用程序时,它会通过 POST 发送有关用户身份验证状态的信息。SDK 处理此数据并验证用户身份。
By telling the JavaScript SDK to reload the page upon successful authentication, Firefox and Internet Explorer interpret this to mean they should send the POST data again, too. Your App receives the POST data again, re-authenticates the user, and reloads the page, causing the infinite loop.
通过告诉 JavaScript SDK 在身份验证成功后重新加载页面,Firefox 和 Internet Explorer 将这解释为它们也应该再次发送 POST 数据。您的应用再次收到 POST 数据,重新对用户进行身份验证,并重新加载页面,从而导致无限循环。
Solution: don't use window.location.reload()
. Instead you'll need to set window.location.href
(or otherwise strip the POST data from the browser request).
解决方案:不要使用window.location.reload()
. 相反,您需要设置window.location.href
(或以其他方式从浏览器请求中去除 POST 数据)。
回答by Jeremy
For those less fluent in Javascript like I am, I'll expound a bit on what Aaron said. At least this is what I dug up after reading his post.
对于像我这样的 Javascript 不太流利的人,我将详细说明 Aaron 所说的内容。至少这是我在阅读他的帖子后挖掘出来的。
window.location.href = window.location.href;
this will replace the document.location.reload();
and works as advertised.
这将取代document.location.reload();
广告中的和 作品。
I ended up having to modify the window.location.href
string because my page behaved differently depending on what page the user came from. So here's my complete method for posterity.
我最终不得不修改window.location.href
字符串,因为根据用户来自哪个页面,我的页面表现不同。所以这是我为后代提供的完整方法。
function RefreshParentPage()
{
//document.location.reload();
var redirectURL = window.location.href;
if (window.location.href.indexOf("showpage=summary") > -1) {
redirectURL = document.location.href.replace("showpage=summary", "showpage=events")
}
window.location.href = redirectURL;
}
回答by Alex Turpin
That means this page was obtained after doing a POST request. The best way to stop that is to redirect to the same page after having processed the POST request in your server code.
这意味着该页面是在执行 POST 请求后获得的。停止这种情况的最佳方法是在服务器代码中处理完 POST 请求后重定向到同一页面。