View Full Version : How can I tell if a frame is done loading?
alpine
11-01-2002, 07:48 PM
Hi all,
I'm using javascript to populate two frames. One loads very quickly, the other takes more time. I want to initiate the document.body.style.cursor = "wait"; and document.body.style.cursor = "default"; events.
I found the parent.frame.loaded() event on a FAQ page - with absolutely no direction on how to use it.:confused:
The code - (main frame)
<html>
<head>
<title>Test Frame</title>
</head>
<frameset rows="72%,*">
<frameset cols="54%,*">
<frame name = "mainmap" src="mapinit.htm" scrolling="auto">
<frame name = "query" src="ppiquery.htm">
</frameset>
<frame name="dataframe" src="searchreturn1.htm" scrolling="auto">
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</html>
The Javascript - (located in ppiquery.htm)
function reportmap(Name)
{
parent.dataframe.location="results.asp?name=" + frmSearch.Name.value;
parent.mainmap.location="map.asp?Cmd=Init&FeatureID=" + frmSearch.Name.value + "&RECID=" + frmSearch.Name.value + "&LABEL=" + frmSearch.Name.value;
}
</script>
Thanks for any help
ConfusedOfLife
11-01-2002, 11:29 PM
You mean you wana have a glass hour for all your 3 pages till the slowest page gets downloaded? If yes, why don't you initiate the cursor for all the pages to be in "wait" status and then define a function for that slow page's onload event to set all the frames cursor status to "default"?
Something like :
onload = "body.style.cursor = 'default'; parent.frames[0].body.style.cursor = 'default'; ..."
alpine
11-02-2002, 03:50 PM
Yep, I've been playing with the onload event in the main frame <frameset> and the pages that load into the frames.
So far I can get the hourglass to come on but can't turn it off.
I will be playing with this later today or tomorro.
Thanks for your response, I will do some more testing and post some code as soon as I can get to it.
Borgtex
11-02-2002, 05:18 PM
A solution:
in all the pages:
<body onload="self.pagecomplete=true"......
in one of the pages or a .js file:
<script>
function checkpgs()
{
idle=true
ix=parent.frames
for (t=0;t<ix.length;t++) idle= idle && ix[t].pagecomplete
if (idle)
{
for (t=0;t<ix.length;t++) ix[t].body.style.cursor = 'default'
clearInterval(pulsar)
}
else
{
//whatever you want
}
}
pulsar=setInterval("checkpgs()",200)
The script (not tested) it's supposed to check all the pages of the frameset until all of them have the value pagecomplete set to true. It doesn't matters wich one it's the fastest or the slowest or how many pages has the frameset
krycek
11-02-2002, 05:44 PM
There is another way, you know...
I am not sure if the onLoad answers have solved your problem, but by using readyState you can tell also.
To find out about readyState I would suggest a quick Google search, but basically, you query the document.readyState property of your frame and then take appropriate action.
For example, if your frame is called myFrame, then:
if (parent.myFrame.document.readyState = "complete") {... etc.
I choose to use the "complete" state because that is when the page is fully loaded, as compared to the other four or five possible states.
NOTE: I know that this technique works in IE, but I am not sure about Netscape, as I don't often need to code for NN.
I hope that helps!
::] krycek [::
ConfusedOfLife
11-03-2002, 09:14 PM
I don't think what Borgtex says work for a page that's a framed page too, I mean nested frames. I still say that it's better that you initiate all your pages by that hourglass and turn all those "wait"s to "default" in the onload event of that slow page.
But I really recommend you to forget about the whole thing coz whenever I see a page that my comp. is waiting for and I see the hourglass, I press those magic keys ( ALT + CTRL + DEL ) and close the page!
Borgtex
11-03-2002, 09:36 PM
Yes it will not work for a framed framed page, but code could be improved to follow all the pages.
I use CTRL + ALT + DEL too; I find hourglasses + ie very... disturbing :)
alpine
11-04-2002, 05:45 PM
Hmmm,
Yep I like the onLoad solution. Or I will when I can get it to work.
So far I have -
<html>
<head>
<title>Test Frame</title>
</head>
<frameset rows="72%,*">
<frameset cols="54%,*" onload="parent.frames['query'].body.style.cursor = 'default';">
<frame name = "mainmap" src="mapinit.htm" scrolling="auto">
<frame name = "query" src="ppiquery.htm">
</frameset>
<frame name="dataframe" src="searchreturn1.htm" scrolling="auto">
<noframes>
<body onload="parent.frames['query'].body.style.cursor = 'default';">
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</html>
The code in the query frame sets the cursor to wait, then passes parameters to an ASP page which builds the HTML for the mainmap frame.
The onload tag for the mainmap frame has the following body tag.
<body onLoad="javascript:setToolImage('<%=sActiveTool%>','2','<%=PRESENTATION_COLOR%>_');parent.frames['query'].body.style.cursor = 'default';">
Strange, when the frame is loaded, the cursor returns to an arrow. Untill you move it. then its back to an hourglass.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.