I'm trying to access the URL of a SharePoint page from within an iframe. It workes fine in IE 9. But not in Firefox or Opera. If I move the script into a common ASP.NET application it works in all browsers.
What is happening in SharePoint when it comes to top and parent?
I have tried with top.location.href, but the problem persists.
This is my JavaScript code:
  try {
    var url = parent.location.href;
    alert(url);
    var index = url.indexOf('SitePages开发者_如何学编程');
    if (index) {
      alert(index);
      url = url.substring(0, index);
      alert(url);
    }
    alert('done');
  }
  catch (ex) {
    alert(ex.Message);
  }
You're experiencing the cross-domain (aka cross-origin) scripting restrictions. If you're the maintainer of the server, the documentation about the Access-Control-Allow-Origin: * header may interest you. This response header should be sent along with your framed web page in order to unlock the ability to script across domains.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论