[英]Frames in javascript
<FRAMESET COLS="*,*" ONLOAD="selectFrames()" ONUNLOAD="alert('stopped')"
<FRAME SRC = "frames/grey.htm" NAME="firstFrame">
</FRAMESET>
<script language="javascript">
function selectFrames(){
base="frame/"
newFrames = new Array("red.htm","blue.htm","pink.htm","grey.htm")
window.firstFrame.location = base+newFrames[Math.round(5*Math.random())%5]
window.secondFrame.location = base+newFrames[Math.round(5*Math.random())%5]
}
its a simple setting frames in grey color buti do not know why is that code is not working. 它是灰色的简单设置框,但是我不知道为什么代码不起作用。 console error is set property location is undefined can anyone guide me about the location of existing code. 设置了控制台错误,属性位置未定义,任何人都可以向我介绍现有代码的位置。
<FRAMESET COLS="*,*" ONLOAD="selectFrames()" ONUNLOAD="alert('stopped')">
<FRAME SRC = "frames/grey.htm" NAME="firstFrame">
<FRAME SRC = "frames/blue.htm" NAME="secondFrame">
</FRAMESET>
<script>
function selectFrames(){
var bs = "frames/",
newFrames = ["red.htm","blue.htm","pink.htm","grey.htm"];
window.frames['firstFrame'].location.href = bs + newFrames[Math.round(Math.random()*5)];
window.frames['secondFrame'].location.href = bs + newFrames[Math.round(Math.random()*5)];
}
</script>
To keep track of syntax errors add this code in your head: 要跟踪语法错误,请在您的头上添加以下代码:
<head><script>
"use strict";
window.onerror = function(msg, url, line){
alert(unescape(msg) + '\nFile: <a href="' + url + '">' + url + '</a>\nat Line: ' + line);
}
</script></head>
Your missing the closing bracket on your <FRAMESET
tag: 您缺少<FRAMESET
标签上的<FRAMESET
括号:
<FRAMESET COLS="*,*" ONLOAD="selectFrames()" ONUNLOAD="alert('stopped')"
Should be: 应该:
<FRAMESET COLS="*,*" ONLOAD="selectFrames()" ONUNLOAD="alert('stopped')">
You're also missing semi-colons from the end of your lines in javascript. 您还会在javascript行尾缺少分号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.