2011-08-18 6 views
13

何らかの理由でchromeがdocument.domainをサポートしなくなり、サブドメインとiframeを含むサブドメインを含むiframeで行が読み取られるとエラーが発生します。とにかくこれの周りにはありますか?document.domainのChromeソリューション

エラー:不明なエラー:SECURITY_ERR:DOM例外18

答えて

15

ドキュメントドメインが小文字である必要があり、ルールはこのようなものです:念の誰に

// Actual domain is "www.foo.com" 
document.domain = "foo.com"; // this is valid 

// Actual domain is "bar.foo.com" 
document.domain = "www.foo.com"; // this is invalid, "bar.foo.com" is not a subdomain of "www.foo.com" 

// Actual domain is "blah.bar.foo.com" 
document.domain = "bar.foo.com" // Ok 
document.domain = "foo.com" // Still ok 
document.domain = "bar.foo.com" // Invalid, you can't change it back to a more specific domain. 
+0

参照を探しています:https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy – juminoz

0

document.domain限り、あなたは、同じドメインにしているとのiframeのために働く必要があります:あなたは、ドキュメントにアクセスしようとしている場合

iframe=document.querySelector('iframe'); 
console.log(iframe.contentDocument.domain) 

親フレームとは別のドメインにあるiframeのうち、あなたが見ているセキュリティエラーが発生します。あなたは、クロスドメインの問題に実行されますので、サブドメインが、あまりにも異なるドメインと見なされていることを

注:A question about cross-domain (subdomain) ajax request

関連する問題