当前位置: 代码迷 >> Web前端 >> iframe访问parent.location.hash疏失
  详细解决方案

iframe访问parent.location.hash疏失

热度:395   发布时间:2012-10-08 19:54:56.0
iframe访问parent.location.hash出错
    在使用iframe来实现跨域访问的时候,一直是通过parent.location.hash来实现父窗口和子窗口之间的通信的,但是需要注意到是:子窗口是不能直接设置parent.location.hash的,因为跨域访问父窗口的location的hash属性是被禁止的,而是应该直接设置parent.location.
    比如原来是设置: parent.location.hash = "#foobar";
    则需要修改为:parent.location = "http://example.com/page/#foobar";

来源:http://stackoverflow.com/questions/4324108/unsafe-javascript-attempt-to-access-frame-with-url
  相关解决方案