Click to See Complete Forum and Search --> : execute script THEN redirect


nash
08-27-2003, 11:15 AM
Okay, here's my problem, I want to have a page load on opening, execute the "typewriter script" and, only when the script has ended, load another page...

What I've done doesn't work... The type writer script works perfectly alone, but it doesn't get to start before the page is redirected (whatever I put as "waiting time")...

I would like to find a way to make the page execute the script and redirect only when it is done...

Here it is anyway:

<html>
<head>
<title>MAIN FRAME LOADING</title>
<META HTTP-EQUIV="Refresh"
CONTENT="3;URL=http://www.../filelist.html">
<base target="contents">
<SCRIPT LANGUAGE="JavaScript">
<!--
function redirect () {
setTimeout("go_now()",3000);
}
function go_now () {
window.location.href = "http://www.../filelist.html";
}
//-->
</SCRIPT>
</head>
<body topmargin="0" leftmargin="0"
bgcolor="#000000">
<DIV ID=ejs_box2_box STYLE="background:#000000;color:#ffffff;
font-familly:fixed width;font-size:14;
width:500;height:145;padding:5"></DIV>
<SCRIPT LANGUAGE=JavaScript>
<!--
/*
letter by letter box
*/
ejs_box2_message = new Array;
ejs_box2_message[0] = '<FONT FACE="Courier New" size="2">
WELCOME TO FILE VIEWER 3.2<br>
LOADING FILE LIST...<br>
RENDERING FILE LIST</FONT>';

ejs_box2_actual = 0;
ejs_box2_html_flag = 0;

function ejs_box2_go()
{
if(document.getElementById)
{
ejs_box2_char = 1;
ejs_box2_affich(ejs_box2_actual)
ejs_box2_actual++;
if(ejs_box2_actual >= ejs_box2_message.length)
ejs_box2_actual = 0;
}
}

function ejs_box2_affich(lactual)
{
var pix = ejs_box2_message[lactual].charAt(ejs_box2_char);
if(pix == "<")
ejs_box2_html_flag = 1;
if(pix == ">")
ejs_box2_html_flag = 0;
var texte = ejs_box2_message[lactual].substring(0,ejs_box2_char);
document.getElementById("ejs_box2_box").innerHTML = texte;
if(ejs_box2_char < ejs_box2_message[lactual].length)
{
ejs_box2_char++;
if(ejs_box2_html_flag == 1)
ejs_box2_affich(lactual);
else
setTimeout("ejs_box2_affich("+lactual+")",100)
}}

window.onload = ejs_box2_go;
//-->
</SCRIPT>
</body>
</html>

Can you help me?:(

luke0
08-27-2003, 12:02 PM
you have to put the file list were it says www......./filelist.html
and your site:eek:

e.g www.mysite.com/hello.html

which WILL load the file


from luke0 (age 14)

:o

David Harrison
08-27-2003, 02:47 PM
Use this script of mine, it has all of the custommizable bits at the top of the script, and includes a redirect once the script has finished.

I noticed another problem in your script by the way, the redirect function was never called.

nash
08-27-2003, 04:31 PM
Thanx for your script but it will not work in my case (execute the "typewriting script" alone to see what I want... Yours apparently cannot do that...

I know the redirect function is not called, it autoexecutes itself when the page loads!

My problem is to find a way of moving the redirect function so that it doesn't executes itself until the "typewriter script" is done...

David Harrison
08-27-2003, 04:45 PM
I removed the line:

window.location.href = "http://www.../filelist.html";

And absolutely nothing happened, so I'm not sure what it is supposed to look like.

nash
08-27-2003, 07:09 PM
:) I've chopped off the whole first script (the redirecting one) and uploaded the resulting page here (http://www.geocities.com/nash_sw2001/violet/typewriterbox.html)...

I think it didn't worked when you tried because I edited the code in my first post so that it doesn't resize the boards too much;) I went to the line after the <br> in my message, which should not be done in the actual script or it gives a "string continuation error"!

Now, the typewriter script works just fine, it's the redirecting one that I can't get to work properly! It redirects before the typewriter starts whatever I put as "waiting time"! It looks like the browser waits to redirect and to start the typewriter script:rolleyes:

nash
08-28-2003, 06:58 AM
:( pleeease! :( Help!

luke0
08-28-2003, 08:44 AM
wot r u on about dude

my site (http://wakeup.to/russells)

David Harrison
08-28-2003, 02:54 PM
OK, I've got a few things to say:

* Never use this <FONT FACE="Courier New" size="2">, it's depreciated and should not be used anymore.

* I could modify my script to look exactly like that in no time. Alternatively you could modify your script to detect when the script has finished writing and then redirect, I would do this for you but I didn't write it and so I can't follow how the script has been written.

* Also your CSS is wrong, here's yours:

<DIV ID=ejs_box2_box STYLE="background:#000000;color:#ffffff;
font-familly:fixed width;font-size:14;
width:500;height:145;padding:5"></DIV>

here's what it should be:

<div id="ejs_box2_box" style="background-color:#000;color:#fff;
font-familly:fixed width;font-size:14px;
width:500px;height:145px;padding:5px;"></div>

I'll be back in a min with a replacement script, (if you're interested).

David Harrison
08-28-2003, 04:07 PM
A bit longer than expected but I went away and did something else as well.