简体   繁体   English

为什么我没有收到跨域错误?

[英]Why am I not getting Cross domain error?

I have a html page which has an Iframe. 我有一个有iframe的html页面。 ( here it is ) 这里是

They are both at different domains. 他们都在不同的领域。

Page A: domain = http://jsbin.com/ 页面A:域= http://jsbin.com/

It hosts an Iframe with domain : Example.com 它托管一个带有域名的Iframe: Example.com

<iframe src='http://example.com' id='a'> </iframe>

However - when I try to access the iframe content via : 但是 - 当我尝试通过以下方式访问iframe内容时:

$(document).ready(function ()
 {
  console.log($("#a").contents().find("*").length)
});

I do see response : 确实看到了回应:

在此输入图像描述

Question : 题 :

why am I not getting an Error about access different origin ? 为什么我没有得到关于访问不同来源的错误?

Comment : It seems that I can't access the content of elements , but i'm positive that I should have got a cross domain error. 评论:似乎我无法访问元素的内容,但我很肯定我应该有一个跨域错误。

relative info : chrome Version 30.0.1599.66 相关信息: chrome版本30.0.1599.66

You don't get an error because the frame hasn't yet loaded so there isn't really anything to block. 您没有收到错误,因为框架尚未加载,因此没有任何阻止。 Try to access it after it loads and you'll see the expected error. 加载后尝试访问它,你会看到预期的错误。

$(document).ready(function (){
  $("#a").load(function(){
   console.log($("#a").contents().find("*").length)
  });
});

http://jsbin.com/uQARiWu/1/edit http://jsbin.com/uQARiWu/1/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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