Html 在iframe中检测重定向
我需要检测iframe何时没有收到它请求的内容,而是被重定向到登录页面 iframe是否处理重定向,或者这是由浏览器完成的?Html 在iframe中检测重定向,html,angular,typescript,iframe,Html,Angular,Typescript,Iframe,我需要检测iframe何时没有收到它请求的内容,而是被重定向到登录页面 iframe是否处理重定向,或者这是由浏览器完成的? 是什么让我这么认为的:load事件只会触发一次,即使之后它的src属性仍然设置为原始URL。假设相同的来源,在给定此测试时,您有以下两种方法: function isFramed() {try {return window.self !== window.top;} catch (e) {return true;}; 这个 或 或者查看如果在同一来源,让登录页面告诉家
是什么让我这么认为的:load事件只会触发一次,即使之后它的src属性仍然设置为原始URL。假设相同的来源,在给定此测试时,您有以下两种方法:
function isFramed() {try {return window.self !== window.top;} catch (e) {return true;};
这个
或
或者查看如果在同一来源,让登录页面告诉家长,或者让登录页面在加载时重定向到_top对不起,你能进一步解释吗?
函数isFramed(){try{return window.self!==window.top;}catch(e){return true;};If(isFramed)window.open(location.href,“_top”);
或函数isFramed(){try{return window.self!==window.top;}catch(e){return true;};if(isFramed)parent.doSomethingHenloginisFramed()
如果控制iFrame的内容,可以使用postMessage标准:
if (isFramed) window.open(location.href,"_top");
if (isFramed) parent.doSomethingWhenLoginIsFramed();