473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Go to new page at the end of my function script

I have a function that loops through a set of images but at the end of
the loop I need the page to go to a new location. Does anyone know how
force my page to go there.

This is what I am thinking

function animateThenGo()
loopimages;
location.href "mypage.htm"

anything that might get me started would be great.

Jul 31 '06 #1
4 9494
VK

Tony wrote:
I have a function that loops through a set of images but at the end of
the loop I need the page to go to a new location. Does anyone know how
force my page to go there.

This is what I am thinking

function animateThenGo()
loopimages;
location.href "mypage.htm"

anything that might get me started would be great.
JavaScript doesn't have commands like "pause" or "sleep" or "resume" or
so. So with your approach the script will loop all images momentarly
and load new page. You need a timer here.
....
function loopImages() {
if (condition) {
// swap image
setTimeout('loopImages()', delay);
}
else {
location.href = 'mypage.html';
}
}

window.onload = loopImages;
....

condition, swap image routine and the desired delay (in ms) are left
for you.

Jul 31 '06 #2
VK said the following on 7/31/2006 12:21 PM:
Tony wrote:
>I have a function that loops through a set of images but at the end of
the loop I need the page to go to a new location. Does anyone know how
force my page to go there.

This is what I am thinking

function animateThenGo()
loopimages;
location.href "mypage.htm"

anything that might get me started would be great.
What you have is a good start, other than the missing = sign after
location.href
JavaScript doesn't have commands like "pause" or "sleep" or "resume" or
so. So with your approach the script will loop all images momentarly
and load new page. You need a timer here.
Yours won't do any better.
function loopImages() {
if (condition) {
// swap image
setTimeout('loopImages()', delay);
}
else {
location.href = 'mypage.html';
}
}
window.onload = loopImages;
There is no need for recursion there. None at all.
condition, swap image routine and the desired delay (in ms) are left
for you.
And a proper logic sequence as well?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 31 '06 #3
VK

Randy Webb wrote:
function loopImages() {
if (condition) {
// swap image
setTimeout('loopImages()', delay);
}
else {
location.href = 'mypage.html';
}
}
window.onload = loopImages;

There is no need for recursion there. None at all.
Where did you see any recursion here? loopImages sets timer, but it
doesn't call itself in the same execution context.
If you have a better idea how to make a timed slideshow without timers
I would like to see it. Something like to try to check the processor
speed and set 10,000-1,000,000 sin-cos calculation loops? ;-)
And a proper logic sequence as well?
I will be glad to further comment the logic for OP and anyone else if
asked.

Aug 1 '06 #4
I have been trying to adapt what you said to this bit of (out of my
league) code.
Would you mind taking a look at it and telling where to insert the if
statement you gave to that will make the page go to the new page after
the images have looped once.

I will be applying this to an imag map next so I can't use the page
load to start the animation. It must start when the user clicks on the
map.

Thanks

<html>
<head>
<SCRIPT>
function ImageAnimator (imgName, imgURLs, spd) {
this.id = ImageAnimator.cnt;
ImageAnimator.elements[ImageAnimator.cnt++] = this;
this.imgName = imgName;
this.imgURLs = imgURLs;
this.spd = spd ? spd : 500;
this.images = new Array(this.imgURLs.length);
for (var i = 0; i < this.imgURLs.length; i++) {
this.images[i] = new Image();
this.images[i].src = this.imgURLs[i];
}
}
function ImageAnimator_play (up) {
if (this.tid)
clearTimeout(this.tid);
this.up = up || typeof up == 'undefined' ? true : false;
if (this.up)
this.cnt = 0;
else
this.cnt--;
if (!this.image)
this.image = document[this.imgName];
if (this.image) {
if (this.up)
this.animateUp();
else
this.animateDown();
}
}
ImageAnimator.prototype.play = ImageAnimator_play;
function ImageAnimator_animateUp () {
this.image.src = this.images[this.cnt].src;
this.cnt++;
if (this.cnt < this.imgURLs.length) {
this.tid = setTimeout('ImageAnimator.elements[' + this.id
+ '].animateUp()', this.spd);
}
else
this.cnt--;
}
ImageAnimator.prototype.animateUp = ImageAnimator_animateUp;
function ImageAnimator_animateDown () {
this.image.src = this.images[this.cnt].src;
this.cnt--;
if (this.cnt >= 0 && this.cnt < this.imgURLs.length) {
this.tid = setTimeout('ImageAnimator.elements[' + this.id
+ '].animateDown()', this.spd);
}
else
this.cnt = 0;
}
ImageAnimator.prototype.animateDown = ImageAnimator_animateDown;
ImageAnimator.cnt = 0;
ImageAnimator.elements = new Array();
</SCRIPT>
<SCRIPT>
var anImageAnimator =
new ImageAnimator (
'anImage',
new Array ('images/Entrance.gif',
'images/EntranceTurn1.gif',
'images/EntranceTurn2.gif',
'images/EntranceTurn3.gif',
'images/EntranceTurn4.gif',
'images/EntranceTurn5.gif',
'images/EntranceTurn6.gif',
'images/EntranceTurn7.gif',
'images/main.gif'),
50
);
</SCRIPT>

<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">

</head>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">

<map name="btnMap">
<area href="javascript: void 0" onclick="anImageAnimator.play(true)"
shape="rect" coords="41, 35, 133, 68">
</map>
<IMG NAME="anImage" SRC="images/Entrance.gif" BORDER="0"
usemap="#btnMap">

</body>
</html>

Aug 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: adrianTNT | last post by:
Hello; Anyone knows how can I create a scrip that returns the google page rank of a given web page? I have seen this on many web pages but I want to host my own script and I dont know how it...
0
by: Question | last post by:
How does one place a graphic image on the HTM page from a java script. I'd like to use the <IMG SRC> function inside the script. <img src="test.gif">
2
by: Raphael Gluck | last post by:
HI I am wondering if anyone can help me I added a little script to a form page, so that a couple of fields have to filled in. One contains an obligatory field for number data, one for regular...
1
by: Don W. | last post by:
I need to use some function keys as speed-keys (instead of clicking a button with the mouse.) Using this code doesn't display any codes for the function keys: <html><body> <SCRIPT...
7
by: ß Ø ® G | last post by:
Hi I'm trying to find a free javascript affect that will make the changes from one page to another in a browser look like the page is curling over as if the pages of a book are turning over....
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
1
by: Ravi | last post by:
Hi , is there a way to invoke a method in asp page from a c# console application. -- ravib
2
by: laurence chang | last post by:
How can I add a print link or button to print current page instead of going to file print? Thanks ahead. Laurence *** Sent via Developersdex http://www.developersdex.com ***
0
by: Eric | last post by:
I have a master page, and want each derived page to have a separate script associated with it. However, I'm not sure where to put the <script> tag. I tried putting it into the Derived.aspx inside...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.