简体   繁体   中英

Accessing facebook through iframe tag and getting a cross origin error

i'm testing this in local host and its getting cross origin error.. how to resolve this problem help me i'm the beginner and i don't have knowledge about that

<script type="text/javascript">
 function iframeLoaded()
  {
      var iFrameID = document.getElementById('idIframe');
      if (iFrameID) 
      {
         iFrameID.height = "";
         iFrameID.height =iFrameID.contentWindow.document.body.scrollHeight + "px";
</script>

<iframe onload="iframeLoaded()" src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/palletech" frameborder="1"..../>

You can't. This is by design, access to content served from other origins (domains, etc.) is protected by the Same Origin Policy . For you to access it from your page on your origin, the other site would have to explicitly give you access, which Facebook will not do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM