Click to See Complete Forum and Search --> : frame loading
sharugan
March 20th, 2008, 11:28 AM
hi ,
i have a frameset that contains two frames.
1)content frame: i have access to this page
2)main frame : i don't have access to this page
I need to write a javascript in content frame to check for the page load in main frame since the main frame page takes much time to load the page.
when i use
if(window.frames['map'].document.readyState == 'complete')
{
}
I am getting not an object error.
I am also looking for script to be compatible across the browser
PeejAvery
March 20th, 2008, 01:20 PM
The propery readyState is for XML. You can use the onload feature.
function functionName() {
...
}
parent.FRAMENAME.onload = functionName;
sharugan
March 20th, 2008, 03:27 PM
thanks for the reply.what i want is a script to find if the second frame page is loaded.
As i said i have two frames in a frameset.I have access to first frame not the second frame.I want to write a script in the first frame to find out if the second frame page is loaded and then show the progress bar in the first frame till the second frame page is loaded..
PeejAvery
March 20th, 2008, 03:55 PM
Which is exactly what my post shows how to do.
sharugan
March 20th, 2008, 04:44 PM
thanks again ,
But when i use parent.FRAMENAME.onload = functionName
[parent.map.onload="progress()";]
in the first frame , i am getting an error that the parent.map is not null or object error.the first frame is not recognizing the second frame name.
PeejAvery
March 20th, 2008, 06:20 PM
So see what the following returns.
var theFrames = parent.document.getElementsByTagName('frame');
for (i = 0; i < theFrames.length; i++) {
alert(theFrames[i].name);
}
sharugan
March 24th, 2008, 03:24 PM
thanks so much ., It works fine now.
parent.map.onload = startclock();
My requirement is , i have two frames in a frameset .I don't have access to secone frame. Hence i need to show progress bar in first frame for the loading of second frame since the second frame takes much time to load.
when i use parent.map.onload = startclock(); , the progress bar is shown .
but when i can't use parent.map.unload = stopclock(); that doesn't work.
could you please help me again, once the form is loaded i want to stop the process bar.
PeejAvery
March 24th, 2008, 04:30 PM
To correctly call a function on an event, you must omit the parenthesis.
parent.map.onload = startclock;
There is no unload event, so of course that won't work. Try...
parent.map.onunload = stopclock;
sharugan
March 25th, 2008, 05:23 PM
thanks for the reply.
I am using a function startclock to show the progress bar while the second frame is loading. i am facing an issue that document.images null or not an object though i have <img > tag in the frame. this is happening in IE6.0
Can you help me
PeejAvery
March 25th, 2008, 07:03 PM
It would save a lot of time, and help us to understand if you could just post your code. Please remember to use [code] tags.
[code]
Your code goes here.
[/code]
sharugan
March 26th, 2008, 11:11 AM
here is the code that gives me document.images is null or not an object.
<script language="javascript">
<!--
var timerID = null;
var pageLoad = null;
var timerRunning = false;
var timeValue = 1000; //the time increment in mS
var count = 0;
var finish = false;
//load up the images for the progress bar
img1 = new Image(); img1.src='img1.gif';
img2 = new Image(); img2.src='img2.gif';
img3 = new Image(); img3.src='img3.gif';
img4 = new Image(); img4.src='img4.gif';
img5 = new Image(); img5.src='img5.gif';
img6 = new Image(); img6.src='img6.gif';
img7 = new Image(); img7.src='img7.gif';
img8 = new Image(); img8.src='img8.gif';
img9 = new Image(); img9.src='img9.gif';
img10 = new Image(); img10.src='img10.gif';
img11 = new Image(); img11.src='img11.gif';
img12 = new Image(); img12.src='img12.gif';
img13 = new Image(); img13.src='img13.gif';
img14 = new Image(); img14.src='img14.gif';
img15 = new Image(); img15.src='img15.gif';
img16 = new Image(); img16.src='img16.gif';
function increment() {
count += 1;
if (count == 1) {document.images.bar.src=img1.src;}
if (count == 2) {document.images.bar.src=img2.src;}
if (count == 3) {document.images.bar.src=img3.src;}
if (count == 4) {document.images.bar.src=img4.src;}
if (count == 5) {document.images.bar.src=img5.src;}
if (count == 6) {document.images.bar.src=img6.src;}
if (count == 7) {document.images.bar.src=img7.src;}
if (count == 8) {document.images.bar.src=img8.src;}
if (count == 9) {document.images.bar.src=img9.src;}
if (count == 10) {document.images.bar.src=img10.src;}
if (count == 11) {document.images.bar.src=img11.src;}
if (count == 12) {document.images.bar.src=img12.src;}
if (count == 13) {document.images.bar.src=img13.src;}
if (count == 14) {document.images.bar.src=img14.src;}
if (count == 15) {document.images.bar.src=img15.src;}
//If you want it to repeat the bar continuously then use this line:
if (count == 16) {document.images.bar.src=img16.src; count=-1;}
//If you want it to stop repeating the bar then use this line:
//if (count == 16) {document.images.bar.src=img16.src; end();}
}
function stopclock() {
//alert("timerRunning"+timerRunning);
if (timerRunning)
clearInterval(timerID);
timerRunning = false;
}
function end() {
if (finish == true) {
stopclock();
window.close();
}
else {
finish = true;
}
}
function startclock() {
//alert("page load yses");
stopclock();
//alert("itsme");
timerID = setInterval("increment()", timeValue);
timerRunning = true;
//alert("itsme pls");
document.images.bar.src=img1.src;
//alert("itsme pls");
}
parent.map.onload = startclock();
parent.map.onunload = stopclock();
//-->
</script>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table border=0 cellpadding=0 cellspacing=0 width="100%">
<tr>
<td colspan="3" nowrap height="25" align="center">
<img src="img0.gif" name="bar" align="middle">
<div id="mydiv"></div>
</td>
</tr>
</table>
</BODY>
</HTML>
PeejAvery
March 26th, 2008, 12:47 PM
Notice that you have your JavaScript calling document.images.bar above the actual HTML for the image itself? That means that the HTML hasn't even loaded the bar image yet. Simply put the HTML above the JavaScript.
sharugan
March 26th, 2008, 05:16 PM
I moved the script down to the table . i am getting "Not implemented " Error.
Please help me
PeejAvery
March 26th, 2008, 05:50 PM
Which line?
sharugan
March 27th, 2008, 11:45 AM
this is the code that gives "Not Implemented " error in IE 6.0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<META NAME="keywords" CONTENT="">
<META NAME="description" CONTENT="">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table border=0 cellpadding=0 cellspacing=0 width="100%">
<tr>
<td colspan="3" nowrap height="25" align="center">
<img src="img0.gif" name="bar" align="middle"/>
</td>
</tr>
</table>
<script language="javascript">
<!--
var timerID = null;
var pageLoad = null;
var timerRunning = false;
var timeValue = 1000; //the time increment in mS
var count = 0;
var finish = false;
//load up the images for the progress bar
img1 = new Image(); img1.src='img1.gif';
img2 = new Image(); img2.src='img2.gif';
img3 = new Image(); img3.src='img3.gif';
img4 = new Image(); img4.src='img4.gif';
img5 = new Image(); img5.src='img5.gif';
img6 = new Image(); img6.src='img6.gif';
img7 = new Image(); img7.src='img7.gif';
img8 = new Image(); img8.src='img8.gif';
img9 = new Image(); img9.src='img9.gif';
img10 = new Image(); img10.src='img10.gif';
img11 = new Image(); img11.src='img11.gif';
img12 = new Image(); img12.src='img12.gif';
img13 = new Image(); img13.src='img13.gif';
img14 = new Image(); img14.src='img14.gif';
img15 = new Image(); img15.src='img15.gif';
img16 = new Image(); img16.src='img16.gif';
function increment() {
count += 1;
if (count == 1) {document.images.bar.src=img1.src;}
if (count == 2) {document.images.bar.src=img2.src;}
if (count == 3) {document.images.bar.src=img3.src;}
if (count == 4) {document.images.bar.src=img4.src;}
if (count == 5) {document.images.bar.src=img5.src;}
if (count == 6) {document.images.bar.src=img6.src;}
if (count == 7) {document.images.bar.src=img7.src;}
if (count == 8) {document.images.bar.src=img8.src;}
if (count == 9) {document.images.bar.src=img9.src;}
if (count == 10) {document.images.bar.src=img10.src;}
if (count == 11) {document.images.bar.src=img11.src;}
if (count == 12) {document.images.bar.src=img12.src;}
if (count == 13) {document.images.bar.src=img13.src;}
if (count == 14) {document.images.bar.src=img14.src;}
if (count == 15) {document.images.bar.src=img15.src;}
//If you want it to repeat the bar continuously then use this line:
if (count == 16) {document.images.bar.src=img16.src; count=-1;}
//If you want it to stop repeating the bar then use this line:
//if (count == 16) {document.images.bar.src=img16.src; end();}
}
function stopclock() {
//alert("timerRunning"+timerRunning);
if (timerRunning)
clearInterval(timerID);
timerRunning = false;
}
function end() {
if (finish == true) {
stopclock();
window.close();
}
else {
finish = true;
}
}
function startclock() {
//alert("page load yses");
stopclock();
//alert("itsme");
timerID = setInterval("increment()", timeValue);
timerRunning = true;
//alert("itsme pls");
document.images.bar.src=img1.src;
//alert("itsme pls");
}
parent.map.onload = startclock();
parent.map.onunload = stopclock();
//-->
</script>
</BODY>
</HTML>
PeejAvery
March 27th, 2008, 12:02 PM
I did not ask for the code, since you have already provided it. I asked for the line on which it occurs.
I fixed my previous post. This is the way to use [code] tags.
[code]
Your code goes here.
[/code]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.