[英]How do I trap a redirect from javascript?
I have this odd bug that causes a 302 redirect to another page on my site and I can't seem to track the source. 我有一个奇怪的错误,导致302重定向到我网站上的另一个页面,我似乎无法跟踪源。 The bug is very random and hard to track.
该错误非常随机且难以跟踪。
I have 2 or more dropdowns on a page for users to select from. 我在页面上有2个或更多下拉菜单供用户选择。 Selecting from the first loads the second, second loads third etc. This is done thru posting back on the onchange event, all .net.
从第一个加载中选择第二个,从第二个加载中选择第三个,依此类推。这可以通过在onchange事件(所有.net)上发回来完成。
Additionally through jquery onblur is wired up to the change event. 另外,通过jquery onblur连接到change事件。 I'm not sure why but I'm guessing that whomever wanted to unselect the dropdown after a selection was made, most likely to prevent a scrolling mouse wheel from changing the selection and causing several post backs.
我不知道为什么,但是我猜想谁在选择之后想要取消选择下拉菜单,最有可能阻止滚动鼠标滚轮更改选择并导致多个回发。
When I unhook the onblur the bug goes away but I need to know whats going on. 当我解开onblur时,错误消失了,但是我需要知道发生了什么。 Some how onblur is causing a sequence of events that results in a 302 redirect without even getting to the server.
一些onblur如何导致一系列事件的发生,这些事件导致302重定向,甚至没有到达服务器。 This would suggest a javascript location change.
这将建议更改javascript位置。 How can I stop at the location change and see what js is triggering this?
我如何才能停止位置更改,看看是什么js触发了这一点?
Any suggestions ? 有什么建议么 ?
Thank you. 谢谢。
重定向是向浏览器(而不是页面)的指令,因此JavaScript无法看到它。
Are you sure it's a 302 causing the location change? 您确定是引起位置更改的302吗? I would start by loading your favorite dev tools (I like chrome) and see if you are actually getting a 302.
我将从加载您喜欢的开发工具(我喜欢chrome)开始,看看您是否真的得到了302。
If you are getting a 302, you're going to have to post some server side code. 如果获得302,则必须发布一些服务器端代码。 If not, I would place some js debug points and go from there.
如果没有,我将放置一些js调试点,然后从那里开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.