我以编程方式在我的网页中设置 iframe 的 url。我必须知道这个 url 更改触发了哪些 http 请求(css、脚本、图像等加载的 url)。我截获了 XMLHttpRequest,但从未调用过这个对象......
我怎样才能拦截那些http请求?
是否有另一种方法可以“加载” iframe 并获取所有触发的 url 请求?
这是我的代码:
(function(xhr){
var pt = xhr.prototype;
pt._open = pt.open;
pt.open = function(){
console.log('Open called...');
this._open.apply(this, arguments);
})(XMLHttpRequest);
...
$('#iframe').attr('src', 'http://www.stackoverflow.com');