Jul 10, 2003 #1 robertd18 Technical User Joined Jan 14, 2003 Messages 32 Location US hi what i mean is how do i program a web page that is using frames to randomly present two frames in random order
hi what i mean is how do i program a web page that is using frames to randomly present two frames in random order
Jul 10, 2003 #2 dwarfthrower Programmer Joined Apr 22, 2003 Messages 1,625 Location AU Store all your frame URLs in an array: Code: var frameURLs = new Array('frame1.html', 'frame2.html', 'frame3.html', 'frame4.html','frame5.html'); Then set the source of each frame randomly: Code: function setframes(){ document.frames[0].src = frameURLs[Math.floor(Math.random()*frameURLs.length]; document.frames[1].src = frameURLs[Math.floor(Math.random()*frameURLs.length]; } Upvote 0 Downvote
Store all your frame URLs in an array: Code: var frameURLs = new Array('frame1.html', 'frame2.html', 'frame3.html', 'frame4.html','frame5.html'); Then set the source of each frame randomly: Code: function setframes(){ document.frames[0].src = frameURLs[Math.floor(Math.random()*frameURLs.length]; document.frames[1].src = frameURLs[Math.floor(Math.random()*frameURLs.length]; }