我在一个页面中,用iframe嵌了一个页面,单击按钮打开iframe页面时,提示
if(document.documentElement.compareDocumentPosition)无权限,这是怎么回事?

解决方案 »

  1.   

    iframe里面的页面是跨域的吧?
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload = function(){
    var ifr = document.getElementById('iframe').contentWindow;
    document.getElementById('click').onclick = function(){
    ifr.location = 'a.html'; 
    };
    };
    </script>
    </head><body>
    <iframe width="300" height="300" id="iframe"></iframe>
    <input type="button" id="click" value="click" />
    </body>
    </html>