[英]dojo: how to execute javascript functions of a page which is loaded by contentPane
我有以下页面:
popup.html
<script type="text/javascript">
//requires
function doFunction(){
alert("hi");
}
</script>
<button dojoType="dijit.form.Button" type="button" onClick="doFunction()">Click me</button>
main.html
<script type="text/javascript">
function showPopUp(){
theContentPane.set("Href", "popup.html");
theModal.show();
}
</script>
<div dojoType="dijit.Dialog" jsId="theModal">
<div dojoType="dojox.layout.ContentPane" jsId="theContentPane">
</div>
</div>
<button dojoType="dijit.form.Button" type="button" onClick="showPopUp()">open popup</button>
当我在main.html中按下按钮"open popup"
时,弹出窗口打开了,一切似乎都很好。 但是当我按下弹出式按钮"click me"
萤火虫时,它显示: doFunction is not defined
是范围问题吗? 我该如何使popup.html调用popup.html中的funciones
在我发布它找到答案之后...。我发布的代码实际上有效,我的无效,因为我有
dijit.layout.ContentPane
代替
dojox.layout.ContentPane
因为dijit.layout.ContentPanel会实例化dojo小部件,但不会执行javascript,而dojox.layout.ContentPane却会执行...
我不使用dojo,但是popup.html中的js似乎没有启动。 将位于popup.html中的脚本标签放在main.html中,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.