Forum Moderators: open

Message Too Old, No Replies

js to call html page with no user interaction

         

TracyQ

9:37 pm on Mar 19, 2011 (gmt 0)

10+ Year Member



Hi!
I'm new here and have searched like mad to find a way to handle this issue to no avail. Here is the problem:

Client wants my flash site converted to html/js/animated gifs. No problem!

BUT, I have an html page that plays a .gif converted from a flash piece. The old flash piece let me script to automatically go to another page after completion of play.

What I need is to find out how to call the next html page from within the page the .gif is on, with no user interaction. All examples I've seen include buttons.

Is there script that I can use on the .gif's html page, to call the main index page without the user having to press anything? I converted the flash piece to .gif but there's no way to embed script in the actual .gif file like there is in flash.

I hope I've been clear on this and thank you all for any help/advice/suggestions!
Tracy

Leosghost

10:56 pm on Mar 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld TracyQ ;-)

Time the anigif beginning to end ( seconds) value = X..set the page to redirect after X plus whatever delay you want
..one way is via meta refresh ..

put this in between the <head> and the </head> tags of your start page

<meta http-equiv="refresh" content="X; URL=other-web-address">

this works if javascript is turned off ..but not all browsers support it

One javascript method would be

<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location="http://www.newpagehere/"; ',10000);
// -->
</script>

the value of 10000 corresponds to an anigif that last 10 seconds ..change it according to the time of the anigif ( in milliseconds ) plus maybe 500 milliseconds extra so as to not have the switch appear to abrupt.

HTH

there are other ways

Fotiman

2:52 am on Mar 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location="http://www.newpagehere/"; ',10000);
// -->
</script>

I would change that to the following:

<script type="text/javascript">
window.setTimeout('window.location="http://www.newpagehere/"; ',10000);
</script>

The language attribute is invalid. Also, HTML comments inside script tags were needed for Netscape 1.0. It hasn't been needed for many years, and is bad practice to still include.

Also, I would set this in the window onload event, so that you know the image has loaded before you set the timeout (so you don't cut off the animation prematurely).



<script type="text/javascript">
window.onload = function () {
window.setTimeout('window.location="http://www.newpagehere/"; ',10000);
};
</script>

Leosghost

3:19 am on Mar 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The language attribute is invalid. Also, HTML comments inside script tags were needed for Netscape 1.0. It hasn't been needed for many years, and is bad practice to still include.

I'm older than you Fotiman ..and learned bad ( obselete ) habits long ago ;-) I often forget that we don't write the "language" and the "comments" nowadays...usually I read your posted javascript stuff and think ..WOW.. "he speaks it like it was English or French or Spanish or something" ..very very impressed ;-)

Pasted that ( script above ) in from a handy dandy scripts library I have had around and growing since the last century ..that I really do need to springclean ..

Forgot the onload too :( ..I don't use javascript that much nowadays.

was filling in until a real expert came by ;-)

In this case I'd probably prefer the meta refresh option .I suspect less people run with browsers that would block it than run with scripting allowed ?

Then again I'm here with Opera ( all scripting allowed ) running on linux ..on a windows box scripting would be off as would be flash ..but then I dont use windows for the web ..only off line and for testing sites on.

TracyQ

6:06 am on Mar 24, 2011 (gmt 0)

10+ Year Member



Thank you so much you guys, you are the greatest!
:o)