简体   繁体   English

使用Firebug时如何防止页面更改

[英]How to Prevent Page Change when using Firebug

I want to inspect the request that will change window.location or whatever it may be using to change the url. 我想检查将更改window.location或可能用于更改url的请求。 I don't know where in the code it is changing the url so I can't put a breakpoint in there. 我不知道代码在哪里更改了网址,因此无法在其中放置断点。

How can I use Firebug to allow Ajax requests but prevent the url from changing? 如何使用Firebug允许Ajax请求,但阻止URL更改? Or how can I otherwise inspect the request that will change the url? 或者我如何才能检查将更改URL的请求?

Thanks! 谢谢!

You can click the "persist" button on the net tab. 您可以单击网络选项卡上的“持久”按钮。 (and other tabs) Was a real "oh duh" moment for me when I noticed it. (和其他标签)当我注意到它时,这对我来说是一个真实的时刻。

You can wrap the ajax request in a function and return false. 您可以将ajax请求包装在函数中并返回false。 Then you can click it and it wont take you away. 然后,您可以单击它,它不会带您离开。 For example, I have a function that looks like this 例如,我有一个看起来像这样的函数

$('.flag-commentflag a').click(function() {
    var url = $(this).attr('href');
    $.get (url, function (data) {
    console.log(data);
    });
 return false;
});

Where .flag-commentflag is the class of the div surrounding the link. 其中.flag-commentflag是链接周围的div的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM