猜想3這是違法的把你frameset
在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>
不要忘記使用http://
而不是file://
爲你的測試Chrome的安全模型考慮每個文件作爲域名打開網頁。
並且不要把for="window" event="onload()"
放在你的腳本元素中:這不是標準化的,並且在非MS瀏覽器上不起作用。你必須使用標準的onload解決方案,就像我的例子。
更正了這一點,這是我的錯誤,frameset不在
標記之內。感謝您提醒我注意。 – gaganHR 2012-07-09 10:37:59當框架集放在頭部和身體之外時,我驗證了'window.frames.length'的值爲'3'。在您撥打電話之前,不要忘記等待文件加載(使用onload)。 – 2012-07-09 10:38:53
哪個版本的Google Chrome?在我的情況下,它仍然顯示0和false: – gaganHR 2012-07-09 10:41:28