在 window.onload 中提交无限循环

发布于 2024-11-04 02:48:51 字数 824 浏览 7 评论 0原文

我有一个问题,当用户打开页面时,它有时会闪烁并自行调整大小。查看日志,似乎提交被多次调用,尽管我不能 100% 确定,因为我无法在自己的环境中重现这一点。

下面的代码中是否有任何您认为不合适的内容,或者我可以检查以查明问题的任何内容。

编辑: .net 页面似乎一直在提供页面,并且在 onload 事件上调用后续的 Submit() ,但它永远不会返回到服务器。我们在一台机器上出现此错误,但在另一台相同的机器上则没有。我想知道这是否可能是负载平衡器的问题。

编辑:我们终于能够重现这个错误。它与通过负载均衡器有关,但仍然不知道问题是什么。这个问题似乎也只是有时发生,如果确实发生,如果您关闭 IE 并重新打开它,它有机会自行修复。

window.onload = function () {
        if (document.getElementById("hfPostBack").value != "true") {
            if (confirm('hfPostBackは:' + document.getElementById("hfPostBack").value + 'です.続行します')) {
                document.getElementById("hfPostBack").value = "true";
                document.forms[0].submit();
            }
        } else {
            alert('hfPostBackは:' + document.getElementById("hfPostBack").value + 'です');
        }
    }

I have an issue that occasionally when a user opens the page it will seemingly flicker and resize itself. Look at the log it seems that the submit is being called multiple times, though i can't be 100% sure since i can't reproduce this in my own environment.

Is there anything in the below code that seems off to you, or anything that i could check to pinpoint the problem.

Edit: It seems that the .net page keeps serving up the page and the subsequent submit() is being called on the onload event, but it's never making it back to the server. We have this bug occuring on one machine but not another identical machine. I wonder if it could be a load balancer issue.

Edit: We have finally able to reproduce this bug. It is related to going through a load-balancer, but still don't know what the problem is. This problem also only seems to occur sometimes and if it does occur, if you close IE and reopen it, it has a chance of fixing itself.

window.onload = function () {
        if (document.getElementById("hfPostBack").value != "true") {
            if (confirm('hfPostBackは:' + document.getElementById("hfPostBack").value + 'です.続行します')) {
                document.getElementById("hfPostBack").value = "true";
                document.forms[0].submit();
            }
        } else {
            alert('hfPostBackは:' + document.getElementById("hfPostBack").value + 'です');
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滿滿的愛 2024-11-11 02:48:51
document.forms[0].submit();

如果代码提交的表单具有该表单所在页面的操作,那么这将导致无限循环。 (加载-提交-加载-提交...)

document.forms[0].submit();

If the form that code is submitting has an action of the same page the form is on, then that will cause an infinite loop. (Load-Submit-Load-Submit...)

傾城如夢未必闌珊 2024-11-11 02:48:51

事实证明,通过将 Web 应用程序的 IIS 安全设置从匿名登录更改为 Windows 身份验证,可以解决该问题。

仍然不知道为什么会发生这种情况,但似乎与负载均衡器传递身份验证信息/模拟有关。

turns out that by changing the IIS security setting for the web app from anonymous logon to windows authentication fixed the problem.

Still have no idea why this was happening, but it seems like it was related to the load-balancer passing authentication information/impersonation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文