我有一个应用程序。在点击按钮时,我尝试打开一个Kendo模态窗口。它已经打开了。我的应用程序在一个域中,而Kendo窗口的内容来自另一个域。现在我想用Kendo窗口内部的按钮关闭模态窗口。问题在这里开始。我无法关闭模态窗口。我使用谷歌搜索过,但没有找到任何解决方案 - 你知道吗?
var myWindow2 = $("#id2").kendoWindow({
modal : true,
draggable: false,
content : {
template: '<a href="javascript:void(0);" id="close2" class="k-button">Close</a>' +
'<iframe src="http://www.xyz.com" frameborder="0" class="k-content-frame"></iframe>'
},
visible : false,
width : 400,
height : 200,
resizable: false,
iframe : true
}).data("kendoWindow");
$("#open2").on("click", function () {
myWindow2.center();
myWindow2.open();
});
$("#close2").on("click", function () {
myWindow2.close();
});
通过为 close
button
定义以下样式,您甚至可以使按钮在页面的其余部分上 float
。
#close2 {
position: absolute;
top: 10px;
left: 10px;
z-index: 10000;
}
var myWindow = $("#id1").kendoWindow({
title : "hi",
visible: false,
modal : true
}).data("kendoWindow");
$("#open").on("click", function () {
console.log("opening");
myWindow.center();
myWindow.open();
});
$("#close").on("click", function () {
console.log("closing");
myWindow.close();
})
还有 HTML
部分:
<a href="#" id="open" class="k-button">Open</a>
<div id="id1">
<p>this is the content of my window</p>
<a href="#" id="close" class="k-button">Close</a>
</div>
iframe
吗? - OnaBaiiframe
来显示页面。如果您的情况是这样的(我认为是这样的),则从另一个网页内部访问容器数据将有严重限制(这些问题取决于浏览器-同源策略-)。 - OnaBaiiframe
来显示窗口内容。如果是这样,您应该能够使用建议的解决方案将myWindow
声明为文档的全局变量(即在$(document).ready(function () {...})
之外),并将定义留在内部不变。 - OnaBai