[英]How can I launch a PARENT jQuery function?
I'm trying to figure out how to launch a function from an iframe but the following example won't work, any ideas? 我试图弄清楚如何从iframe启动功能,但以下示例将不起作用,有任何想法吗?
<input class='reply' onclick='parent.replytopost()' type='button' value='Reply' />
PARENT PAGE FUNCTION (In the body if that makes a difference): 父页面功能(如果有所不同,则在体内):
<script>
function replytopost(){
alert("test");
parent.document.getElementById('mainbar').innerHTML = "TEST";
parent.document.getElementById('post_reply').show();
}
</script>
This might become an issue with security-tightened browsers (such as Safari). 对于安全性较高的浏览器(例如Safari),这可能会成为问题。
I ran against the same type of problem recently, and I'm now a happy user of window.postMessage . 我最近遇到了相同类型的问题,现在我是window.postMessage的快乐用户。
You will still have to reference it using window.parent
but this will prevent the vast majority of issues to happen. 您仍然必须使用
window.parent
来引用它,但这将防止发生绝大多数问题。
Will window.opener
work for you? window.opener
对您window.opener
吗? I know it works from a parent to a newWindow. 我知道它可以从父级到newWindow。 I don't know about iframe.
我不了解iframe。
http://www.w3schools.com/jsref/prop_win_opener.asp http://www.w3schools.com/jsref/prop_win_opener.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.