gpt4 book ai didi

ajax - 在javascript中获取iframe重定向url

转载 作者:行者123 更新时间:2023-12-04 23:05:54 25 4
gpt4 key购买 nike

我正在对后端服务器上的页面执行 iframe 请求。该页面执行重定向并返回与所请求的相同的 url,但还会附加一个查询字符串。我怎样才能得到返回的 url 和查询字符串?我的 ajax 类如下所示:

var ajax =
{
send: function(urlstring)
{
if(!this.ifram)
{
this.ifram = document.createElement('iframe');
this.ifram.style.display = 'none';
if(this.ifram.addEventListener) this.ifram.addEventListener('load',ajax.receive,false);
else if(this.ifram.attachEvent) this.ifram.attachEvent('onload',ajax.receive);
document.body.appendChild(this.ifram);
}
this.ifram.setAttribute('src',urlstring);
},
receive: function()
{
content = ajax.ifram.contentWindow.document.body.innerHTML;
returnurl = ajax.ifram.src;
alert('return url: '+returnurl);
}
};

但是 returnurl 始终保留原始 urlstring 值,即使响应不同也是如此。

干杯彼得

最佳答案

returnurl = ajax.ifram.contentWindow.location.href 就可以了:)

关于ajax - 在javascript中获取iframe重定向url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6537162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com