Forum Moderators: open
and, if possible, I'd prefer to keep all of this in one *.htm file.
Here's what I have so far. The JavaScript runs, but it tells me "secfr is not defined."
<html> [/code]
[code]<body> <frameset cols="55%,45%"> <frame name="firstfr" id="firstfr" src="http://www.google.com/search?q=this+is+the+left+frame" /> <frame name="secfr" id="secfr" src="src="http://www.google.com/search?q=i+want+day+number+here" /> </frameset> </body> [/code]
[code]<script language = "JavaScript" type="text/javascript"> var now = new Date(); var myArray = new Array("1","1","2","3","4","5","1"); var str = myArray[now.getDay()]; secfr.location = "http://google.com/search?q=the+day+is+num+" + str + "!"; </script> [/code]
[code]</html> Oh, and things I've already tried:
- "src" instead of "location"
- parent.secfr
- parent.frames[2].secfr
- window.secfr
- top.secfr
[edited by: awefawe at 9:54 am (utc) on Mar. 11, 2009]
document.getElementById( "secfr" ).src =
I assume src="src=" is a transcription error
Remove the body tags, frameset is replacement for body.
Alternative would be to replace
<frame name="secfr" id="secfr" src="src="http://www.google.com/search?q=i+want+day+number+here" />
with
<script language = "JavaScript" type="text/javascript">
var now = new Date();
var myArray = new Array("1","1","2","3","4","5","1");
var str = myArray[now.getDay()];
document.write( '<frame name="secfr" id="secfr" src="http://google.com/search?q=the+day+is+num+' + str + '!" />';
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> [/code]
[code]<frameset cols="55%,45%"> <frame name="firstfr" id="firstfr" src="http://www.google.com/search?q=this+is+the+left+frame" /> <frame name="secfr" id="secfr" src="http://www.google.com/search?q=i+want+day+number+here" /> </frameset> [/code]
[code]<script language="JavaScript" type="text/javascript"> <!-- var now = new Date(); var myArray = new Array("1","1","2","3","4","5","1"); var str = myArray[now.getDay()]; alert(str); /* just to test if script is running at all */ document.getElementById( "secfr" ).src = "http://google.com/search?q=the+day+is+num+' + str + '!"; //--> </script> [/code]
[code]</html> I can't seem to get the script to execute at all...