日期:2014-05-16  浏览次数:20293 次

JS 报错 没有权限

JS 报错 没有权限
2010年12月13日
  没有权限是因为js脚本有"不能跨域访问",只能在相同域访问的规定!只需在脚本加入document.domain="域名"即可
  以下是测试代码:
  main.html  
  
  
  
  
  
  
   
  left.html 
  
  
  //document.domain="192.168.153.68";
  function leftfun()
  {
  alert("left");
  }
  function test()
  {
  parent.frames[1].rightfun();
  }
  
  
  
  
  
   right.html 
  
  
  document.domain="192.168.153.68";
  function rightfun()
  {
  alert("right");
  }
  function test()
  {
  parent.frames[0].leftfun();
  }
  
  
  
  
  
   //原文http://hi.baidu.com/cheng32/blog/item/d24d28a86708 49bcca130c76.html