简体   繁体   English

如何捕获来自javascript的重定向?

[英]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.

相关问题 我如何从表格中捕获文本区域以外的内容 - How do I trap enter from form except textarea 如何使用Javascript或jQuery重定向网页? JavaScript重定向 - How do I redirect my webpage with Javascript or jQuery ?? Javascript redirect 如何在JavaScript中重定向到带有变量的网址? - How do I Redirect to an url with variables in JavaScript? 如何捕获Javascript弹出的未知原因? - How can I trap the unknown cause of a Javascript popup? 如何在ASP.Net MVC中进行JavaScript重定向? - How do I do a JavaScript redirect in ASP.Net MVC? 如何使用javascript从html登录表单重定向到欢迎页面? 该站点处于脱机状态并且在开发服务器上 - how do i redirect to a welcome page from a html login form using javascript? The site is offline and on a development server 如何使用 Z686155AF75A60A0EDD3F6E9D80C1 从 ASP.NET Controller 重定向到另一个 web 页面? - How do I redirect to another web page from an ASP.NET Controller using JavaScript? 如何重定向没有 www 的页面。 到万维网。 用javascript? - How do I redirect a page from not having www. to www. with javascript? 使用JavaScript下载后如何重定向到新页面? - How do I redirect to a new page after a download using Javascript? 如何在响应重定向之前调用javascript - How do I call javascript just before a response redirect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM