[英]Passing javascript variable from parent to iframe
So I have a variable in my page body like so: 所以我的页面正文中有一个变量,如下所示:
<script>
var myClick = false;
</script>
And a jquery ui dialog with iframe content. 以及带有iframe内容的jquery ui对话框。 Now I want to check the variable on jquery ui dialog like -
现在我想检查jQuery UI对话框上的变量,例如-
<script>
if(myClick == true){
// code somthing
}
</script>
What is the simplest way to do that? 最简单的方法是什么?
If the iframe is on the same domain you can use window.parent.myClick
如果iframe位于同一域中,则可以使用
window.parent.myClick
if (window.parent.myClick === true) {
// code somthing
}
See Plunker example 请参阅柱塞示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.