Chrome と firefox でこの問題が発生しました。関数crse_FrameExists()内のwindow.frames.lengthは、実際には値 3 と true を返して続行する必要がある場合に、常にゼロを返します。IE9では問題ありません。なぜこれが起こるのか誰にも分かりません。回避策は役に立ちます...ありがとう、以下のコードスニペット:
alert(window.frames.length);
IE では想定どおり 0 から 3 を返します
Chrome と firefox でこの問題が発生しました。関数crse_FrameExists()内のwindow.frames.lengthは、実際には値 3 と true を返して続行する必要がある場合に、常にゼロを返します。IE9では問題ありません。なぜこれが起こるのか誰にも分かりません。回避策は役に立ちます...ありがとう、以下のコードスニペット:
alert(window.frames.length);
IE では想定どおり 0 から 3 を返します
または にyourframeset
を入れることは違法です。head
body
head
(なし)の直後に置くとbody
問題ありません。
例えば :
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script>
function crse_FrameExists(frameName){
for (i = 0; i < window.frames.length; i++) {
if (window.frames[i].name == frameName) return(true);
}
return(false);
}
window.onload=function(){
alert("crse_FrameExists('fra_header'):" + crse_FrameExists('fra_header') );
};
</script>
</head>
<frameset id="Nav4mainFrameset" framespacing="0" border="false" frameborder="0" rows="76,*">
<frame name="fra_minimain" id="fra_minimain" scrolling="no" noresize src="index2.html">
<frameset cols="188,*">
<frame name="fra_header" id="fra_header" scrolling="no" noresize src="index2.html">
<frame name="fra_content" id="fra_content" scrolling="auto" noresize src="index2.html">
</frameset>
</frameset>
</html>
Chrome のセキュリティ モデルは各ファイルをドメインと見なすため、テスト用http://
ではなくを使用してページを開くことを忘れないでください。file://
for="window" event="onload()"
また、スクリプト要素を入れないでください。これは正規化されておらず、MS 以外のブラウザーでは機能しません。私の例のように、標準のオンロード ソリューションを使用する必要があります。