ページからfile://localhost/Users/pistacchio/dev/epress/catflow/test_html/index.html
、iframe にアクセスしようとしている次の (coffeescript) コードがあります。
$('#ipad-viewport iframe').bind 'load', () ->
console.log $(this).contents().find('map')
(これは次の JavaScript に変換されますが、問題はここに依存しているとは思いません):
(function() {
$('#ipad-viewport iframe').bind('load', function() {
return console.log($(this).contents().find('map'));
});
}).call(this);
iframe ページが読み込まれるのを待って、その本文内の要素にアクセスしようとします。次のエラーが表示されます。
Unsafe JavaScript attempt to access frame with URL file://localhost/Users/pistacchio/dev/epress/catflow/test_html/catalogo/catalog/intro.html from frame with URL file://localhost/Users/pistacchio/dev/epress/catflow/test_html/index.html. Domains, protocols and ports must match.
さて、iframeは次のように定義されているので:
<iframe src="file://localhost/Users/pistacchio/dev/epress/catflow/test_html/catalogo/catalog/intro.html" width="1024" height="768"></iframe>
ページと iframe の両方が同じドメインにありfile://localhost
ませんか? この問題が発生するのはなぜですか?
ああ、関連する場合は、Chrome 18 でこれをテストしています。