2012-04-08 15 views
0

編集:動作します(申し訳ありません)。このスクリプトで何か、それはGoogleのクロムに停止する原因になっている:Google Chromeのiframe body onLoadが機能していませんか?

function checkLocation() { 
    var loc = top.location.href; 
    var suffix = "subpage.html"; 
    if (loc.indexOf(suffix, loc.length - suffix.length) !== -1) { 
     top.location.href = "index.html"; 
    } 
} 

オリジナルのポスト:

私はIE 9、FF 3.6.3、クロム(18.0.1025.151)とSafari 5.1を持っています。 5すべてがインストールされています。

これはgoogle chrome以外のすべてのブラウザで機能します。

私は名前付きiframeを含むHTMLレイアウトを持っています。 iframe srcが異なるページを表示するように変更されます。ページの1つに、bodyタグにonLoadを読み込んだスクリプトがあります。このスクリプトは、ページがgoogle chromeのiframeに読み込まれたときに読み込まれません。他のブラウザでも正常に動作します。また、Googleのchrome(iframe経由ではありません)に直接ページを読み込むと、うまく動作します。

これを修正するにはどうすればよいですか?探しているため

index.html 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> <head> <title> Example Page </title> </head> 
     <body> <a href="subpage.html" target="targetFrame">View subpage</a><BR/> 
       <iframe name="targetFrame"> </iframe> 
     </body> 
</html> 

subpage.html 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html> <head> <title> Subpage </title> 
       <script type="text/javascript" src="subpage.js"> </script> 
     </head> 
     <body onLoad="initialise()"> Hello </body> 
</html> 

subpage.js 
function initialise() { 
    alert("Script loaded."); 
} 

ありがとう:ここ

は、サンプルコードです。

答えて

0

が、それは問題ないはず同社のオンラインたら

Unsafe JavaScript attempt to access frame 
with URL file:///C:/Users/.../website/index.html 
from frame 
with URL file:///C:/Users/.../website/subfolder/subpage.html. 
Domains, protocols and ports must match. 

そのわずかセキュリティ例外が判明します。

関連する問題