index.html<html><head><script type="text/javascript" src="easyui/jquery.min.js"></script></head><body> <iframe src="iframe.html"></iframe></body></html>iframe.html<html><head><link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"><link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"><script type="text/javascript" src="easyui/jquery.min.js"></script><script type="text/javascript" src="easyui/jquery.easyui.min.js"></script><script type="text/javascript"> $(function(){ $("#window").window({ width: 200, height: 100 }); });</script></head><body> <div id="window"></div></body></html>效果由于是在iframe中彈窗致使窗口被腰斬,所以需要向window中追加節(jié)點(diǎn)再彈窗,解決方式如下 var win = window.top.document.createElement("div"); window.top.document.body.appendChild(win); window.top.$(win).window({ width: 200, height: 100 }); window.top.$(win).window("open");但在實(shí)際項(xiàng)目中無法向index.html引入easyui相關(guān)類庫,所以會報(bào)錯(cuò)什么call、apply、__proto__之類的辦法都想過了,不知道該怎么辦了...
JavaScript:關(guān)于跨iframe彈窗
炎炎設(shè)計(jì)
2019-03-14 18:15:01