如何使用 js 跟踪 iframe 的导航

How to track nevigation of iframe using js

提问人:Isha Lad 提问时间:7/25/2023 更新时间:7/25/2023 访问量:40

问:

我正在使用 iframe 显示另一个跨平台网站 我想知道用户在 iframe 标记中访问的 url 我知道它需要同源策略,但它不允许 当用户更改导航并刷新父页面时,iframe 将返回到原始阶段,但我想将其更改为用户上次在 iframe 中访问的页面。可能吗? 我试过这个:

iframe.contentWindow.console[logType] = function() {
    logUtil.log.apply(logUtil, arguments);
    original.apply(iframe.contentWindow.console, arguments);
};
javascript html jquery url iframe

评论

0赞 CBroe 7/25/2023
您无法访问从其他源加载的 iframe 的 URL。只有当其他网站愿意与您积极合作,使用与嵌入它的页面交换信息时,您想要的才有可能。postMessage

答: 暂无答案