index.html
iframe.html
$(function(){
$("#window").window({
width: 200,
height: 100
});
});
效果
由于是在iframe中弹窗致使窗口被腰斩,所以需要向window中追加节点再弹窗,解决方式如下
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");
但在实际项目中无法向index.html引入easyui相关类库,所以会报错
什么call、apply、__proto__之类的办法都想过了,不知道该怎么办了...
====================临时解决办法==========================
$(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");
}