查看“︁Iframe”︁的源代码
来自康健生活
←
Iframe
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 跳转 == === 向父级跳转 === iframe 在登录页面中加入下面的代码,就会在最外层页面跳转 <syntaxhighlight lang="html5"> <script language="JavaScript"> if (window != top) top.location.href = location.href; </script></syntaxhighlight> ==== 微信登陆 ==== 在做微信登陆的时候遇到,微信扫描二维码,但是跳转只在 iframe 中跳转,没有跳到父级。 需要在微信接口配置参数中设置 <code>self_redirect:false</code> == 事件 == === IE === <syntaxhighlight lang="javascript"> iframe?.contentDocument?.addEventListener('readystatechange', iframeHandleListener, {passive: false}); </syntaxhighlight> eq: <syntaxhighlight lang="javascript"> //check for IE if (navigator.userAgent.indexOf("MSIE") > -1 && !window.opera){ iframe.onreadystatechange = function(){ if (iframe.readyState == "complete"){ alert("Iframe is loaded."); } }; } else { iframe.onload = function(){ alert("Iframe is loaded."); }; }</syntaxhighlight> === 非 IE === <syntaxhighlight lang="javascript"> iframe?.contentDocument?.addEventListener('load', iframeHandleListener, {passive: false}); </syntaxhighlight> == load == === inline javascript === <syntaxhighlight lang="html"> <script> const onHandleLoad = () => console.log('iframe is loaded'); </script> <iframe id="iframe" src="https://kangkk.com" onload="onHandleLoad(this)"></iframe></syntaxhighlight> === javascript === <syntaxhighlight lang="html"> <script> document.getElementById('iframe').onload = () => console.log('iframe is loaded'); </script> <iframe id="iframe" src="https://kangkk.com"></iframe></syntaxhighlight> === addEventListener === <syntaxhighlight lang="html"> <script> const iframe = document.getElementById('iframe'); const onHandleLoad = () => console.log('iframe is loaded'); iframe.addEventListener('load', onHandleLoad, true); </script> <iframe id="iframe" src="https://kangkk.com"></iframe></syntaxhighlight> === Observables === <syntaxhighlight lang="javascript"> <script> import { fromEvent } from 'rxjs'; const iframe = document.getElementById('iframe'); fromEvent(iframe, 'load').subscribe(() => console.log('iframe is loaded'); </script> <iframe id="iframe" src="https://kangkk.com"></iframe></syntaxhighlight>
返回
Iframe
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。