Reputation: 73
<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.
Upvotes: 0
Views: 281
Reputation: 2350
Your missing the closing bracket on your <FRAMESET
tag:
<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.
Upvotes: 0
Reputation: 370
<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>
Upvotes: 1