javascript
html点击弹出iframe,JavaScript:关于跨iframe弹窗
index.html
iframe.html
$(function(){
$("#window").window({
width: 200,
height: 100
});
});
效果
由于是在iframe中彈窗致使窗口被腰斬,所以需要向window中追加節(jié)點(diǎn)再?gòu)棿?#xff0c;解決方式如下
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)目中無(wú)法向index.html引入easyui相關(guān)類庫(kù),所以會(huì)報(bào)錯(cuò)
什么call、apply、__proto__之類的辦法都想過(guò)了,不知道該怎么辦了...
====================臨時(shí)解決辦法==========================
$(function() {
var script = parent.document.createElement("script");
script.type = "text/javascript";
script.src = "easyui/jquery.easyui.min.js";
parent.document.getElementsByTagName("head")[0].appendChild(script);
var link1 = parent.document.createElement("link");
link1.rel = "stylesheet";
link1.type = "text/css";
link1.href = "easyui/themes/default/easyui.css";
parent.document.getElementsByTagName("head")[0].appendChild(link1);
var link2 = parent.document.createElement("link");
link2.rel = "stylesheet";
link2.type = "text/css";
link2.href = "easyui/themes/default/easyui.css";
parent.document.getElementsByTagName("head")[0].appendChild(link2);
});
function click() {
var win = parent.document.createElement("div");
parent.document.body.appendChild(win);
parent.$(win).window({
width : 200,
height : 100
});
parent.$("#div").window("open");
}
總結(jié)
以上是生活随笔為你收集整理的html点击弹出iframe,JavaScript:关于跨iframe弹窗的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 设置mtu值使网速达到最快详细步骤
- 下一篇: 笔记本电脑电源是哪个牌子好(电脑的电源什