Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q4 Is there a script out there that will load a certain frame first?

You are here: irt.org | FAQ | JavaScript | Frame | Q4 [ previous next ]

This effect can be achieved by loading dummy frames to start with, and then using the onLoad event to change the location of other frames:

<html>
<head>
<script language="JavaScript"><!--
function load_next(frame) {
if (frame == 2)
    window.frameName2.location.href = "frame2.html";
else if (frame == 3)
    window.frameName3.location.href = "frame3.html";
else if (frame == 4)
    window.frameName4.location.href = "frame4.html";
else if (frame == 5)
    window.frameName5.location.href = "frame5.html";
}
//--></script>
</head>

<frameset rows="20%,20%,20%,20%,20%" onLoad="load_next(2)">
<frame src="frame1.html" name="frameName1">
<frame src="dummy.html"  name="frameName2">
<frame src="dummy.html"  name="frameName3">
<frame src="dummy.html"  name="frameName4">
<frame src="dummy.html"  name="frameName5">
</frameset>
</html>

When all the frames have been loaded, the onLoad event within the frameset will use the load_next() function to change the contents of frameName2.

The contents of frame2.html would then need to contain the following:

<body onLoad="parent.load_next(3)">

When frame2.html is loaded the onLoad event in the body tag will use the load_next() function in the parent frame to change the contents of frameName3 etc. etc.

©2018 Martin Webb