Hi, just hoping someone can point me in the right direction.
I have the code below, and clearTimeout doesn't seem to be ever called, or if it is, it doesn't have the desired effect.
The desired effect, is that when onresize is fired, it then calls the resize function, which then executes the clearTimeout.
I have tried using it as in the code below, and directly following the setTimeout in the functions (so instead of calling the function it just directly executes clearTimeout, and neither has had the desired effect.
Any help would be very much appreciated.
Code:
<html>
<head>
<meta http-equiv="Page-Enter" content="RevealTrans(duration=2,transition=23)">
<script language="JavaScript">
function SSS()
{
var t;
t=setTimeout("Slide1()",3000);
}
function resize()
{
clearTimeout(t);
}
function Slide1()
{
var x = document.frames.MainFrame.location="lib/one.html";
x = null;
t=setTimeout("Slide2()",8000);
}
function Slide2()
{
var x = document.frames.MainFrame.location="lib/two.html";
x = null;
t=setTimeout("Slide1()",8000);
}
</script>
</head>
<body onLoad="SSS()" onresize="resize()">
<iframe id="MainFrame" Src="lib/one.html" width="100%" height="100%" frameborder="0">
</iframe>
</body>
</html>
first, the reference to the iframe window is wrong. frames generate a new separate window object. when you refer a frame by it's id you get the element, not the window object of that frames. however, there are two way you can get the window object: using the frames object or reading the object contentWindow from the iframe element. what follow is how you write it:
second, there is a chance browser throw error when resize is done before any of the slide function is called. that is because the variable t is defined as local to that function. remove the var statement in function SSS.
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
Thank you for that. I made those changes as you suggested, and tested it.
It still didn't have the desired effect, as when the resize occured, the slideshow stopped and never started again. But I'm pretty sure that means that the resize function was called as desired, just that it didn't then break out of the setTimeout and continue, which is the desired effect. So thank you very much for your help, seems to me that it's pretty close to working the way I want now.
So if anyone could help with working out what other changes are needed, it would be very much appreciated.
then there is no reason to clear the timeout. just don't stop the timeout so that it continue changing the document. unless you have a reason for stopping it when resize occur.
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
if i correctly understood the argument, problem is that browser don't have an event for detecting when resize is done so that you can resume the slide.
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
if i correctly understood the argument, problem is that browser don't have an event for detecting when resize is done so that you can resume the slide.
That's correct, I want it to detect when the resize event occurs and then straight away go to the next slide, which will then detect the size.
sorry to mention, but there is no such event; as far as i know. and can't think of a solution
my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous. my nature language is javascript, then come spanish and english -- me
Sorry, perhaps I have not been clear enough in my explaination.
It seems to detect the resize correctly with this piece of code:
Code:
<body onLoad="SSS()" onresize="resize()">
All I need to do is get the timeout to finish early when this event occurs and then have it resume normal operation.
I have been able to find snippits of code that do these things - detect the resize event and react, set a timeout, end the timeout early and then resume - but I'm at a loss as to why it doesn't work as I expect it to.
Maybe the fault lays with the
Code:
setTimeout("Slide1()",8000);
existing in a function and calling another function at the end of the timeout? I'll try that but it seems like a bit of a longshot to me.
Bookmarks