Javascript iframe中的回调方法将值返回到opener

Javascript iframe中的回调方法将值返回到opener,javascript,static,methods,mootools,Javascript,Static,Methods,Mootools,我必须在iframe中调用回调方法来向opener返回一个值 我知道有“分配、打开、关闭”静态方法,但我不明白它是如何工作的,有人能帮我吗?我对挤压盒不太了解,但我在iframe通信方面做了一些工作。除非iFrame和opener在同一个域中,否则不能从一个域调用另一个域 为了解决这个问题,我所做的是写入URL的哈希。然后,开瓶器可以读取该值并确定要执行的操作 比如说, <iframe name="my-frame" id="my_frame" src="http://www.somewh

我必须在iframe中调用回调方法来向opener返回一个值


我知道有“分配、打开、关闭”静态方法,但我不明白它是如何工作的,有人能帮我吗?

我对挤压盒不太了解,但我在iframe通信方面做了一些工作。除非iFrame和opener在同一个域中,否则不能从一个域调用另一个域

为了解决这个问题,我所做的是写入URL的哈希。然后,开瓶器可以读取该值并确定要执行的操作

比如说,

<iframe name="my-frame" id="my_frame" src="http://www.somewhere.com" width="540" height="1000" border="0" style="overflow:hidden; border: none;">
   <script type="text/javascript">window.location.hash = 'close';</script>
</iframe>

<script type="text/javascript">

  // Function to look for a token in the url hash 
  var tokenValue = function(){
    var hash = document.location.hash;
    return (hash && hash.length > 1) ? hash.substring(1, hash.length) : null;
  };

  // Function to set the token and notify the user when it is found in the url hash.
  var checkForToken = function(){
    if (tokenValue()) {
      alert(tokenValue());
      $clear(periodical);
    }
  };

  // Start a periodical that will check for
  var periodical = checkForToken.periodical(100);
</script>

window.location.hash='close';
//函数在url哈希中查找令牌
var tokenValue=函数(){
var hash=document.location.hash;
返回(hash&&hash.length>1)?hash.substring(1,hash.length):null;
};
//函数设置令牌,并在url哈希中找到令牌时通知用户。
var checkForToken=函数(){
if(tokenValue()){
警报(tokenValue());
$clear(定期);
}
};
//开始一份定期检查
var定期=定期支票(100);

自己回答。我已经解决了挤压盒功能,谢谢。