On page load, is it possible to write out something to the browser
using
document.write("blah blah ...");
And then pause for 2 seconds and write out something else like
document.write("something funny...");
Javascript does not seem to have a sleep function. I've tried
setTimeOut("myFunction()", mydelay);
It does not work.
Any idea? Thanks.
Martin Honnen - 28 Dec 2007 16:11 GMT
> On page load, is it possible to write out something to the browser
> using
[quoted text clipped - 4 lines]
>
> document.write("something funny...");
document.write after page load overwrites the the document. And blocking
the page load for two seconds does not sound like a good idea. But you
can easily create and add contents after page load e.g.
var p = document.createElement('p');
p.appendChild(document.createTextNode("something funny..."));
document.body.appendChild(p);

Signature
Martin Honnen
http://JavaScript.FAQTs.com/
My Pet Programmer - 28 Dec 2007 16:11 GMT
gnewsgroup said:
> On page load, is it possible to write out something to the browser
> using
[quoted text clipped - 12 lines]
>
> Any idea? Thanks.
setTimeout works perfectly. Just because it doesn't do what you want it
to does not mean it does not work.
That said, I have a hack I stopped using a while ago because I decided I
didn't want to pause things for any good reason, and here you go:
function pause(millis) {
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}
~A!

Signature
Anthony Levensalor
anthony@mypetprogrammer.com
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein
Lee - 28 Dec 2007 18:17 GMT
My Pet Programmer said:
>gnewsgroup said:
>> On page load, is it possible to write out something to the browser
[quoted text clipped - 26 lines]
> while(curDate-date < millis);
>}
Please don't post such horrors to this newsgroup.
You should NEVER use code like that in a web page.
--
My Pet Programmer - 28 Dec 2007 19:01 GMT
Lee said:
> My Pet Programmer said:
>> gnewsgroup said:
[quoted text clipped - 30 lines]
> Please don't post such horrors to this newsgroup.
> You should NEVER use code like that in a web page.
I tend to agree, and I wouldn't. Haven't used that crud in so long I
can't even remember. But he wanted it, so I gave it to him.
~A!

Signature
Anthony Levensalor
anthony@mypetprogrammer.com
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein
Lee - 28 Dec 2007 19:19 GMT
My Pet Programmer said:
>Lee said:
>> My Pet Programmer said:
[quoted text clipped - 34 lines]
>I tend to agree, and I wouldn't. Haven't used that crud in so long I
>can't even remember. But he wanted it, so I gave it to him.
I understand, but giving people what they ask for isn't always
doing them a service. There's also the risk that other people
will find it via a search and think it's a recommended solution.
--
My Pet Programmer - 28 Dec 2007 19:40 GMT
Lee said:
> My Pet Programmer said:
>> Lee said:
[quoted text clipped - 38 lines]
> doing them a service. There's also the risk that other people
> will find it via a search and think it's a recommended solution.
Good point. I apologize to all future readers of this thread in advance.
Don't use that code, I used it years ago when I was also using
document.all, and I just threw up in my mouth a little bit.
~A!

Signature
Anthony Levensalor
anthony@mypetprogrammer.com
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein
Lee - 28 Dec 2007 20:32 GMT
My Pet Programmer said:
>Lee said:
>> My Pet Programmer said:
[quoted text clipped - 43 lines]
>Don't use that code, I used it years ago when I was also using
>document.all, and I just threw up in my mouth a little bit.
And I just laughed out loud.
--
-Lost - 30 Dec 2007 10:08 GMT
Response to Lee <REM0VElbspamtrap@cox.net>:
>>Good point. I apologize to all future readers of this thread in
>>advance. Don't use that code, I used it years ago when I was also
>>using document.all, and I just threw up in my mouth a little bit.
>
> And I just laughed out loud.
Yeah, that was definitely good. You're making a great impression,
Anthony.
Definitely a true underdog story. ; )

Signature
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Thomas 'PointedEars' Lahn - 30 Dec 2007 10:47 GMT
> Response to Lee <REM0VElbspamtrap@cox.net>:
>>> Good point. I apologize to all future readers of this thread in
[quoted text clipped - 6 lines]
>
> Definitely a true underdog story. ; )
He apologized already. There is no need to beat a dead horse.
I think another apology would be in order now.
PointedEars

Signature
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
-Lost - 30 Dec 2007 10:50 GMT
Response to Thomas 'PointedEars' Lahn <PointedEars@web.de>:
>> Response to Lee <REM0VElbspamtrap@cox.net>:
>>>> Good point. I apologize to all future readers of this thread in
[quoted text clipped - 11 lines]
>
> I think another apology would be in order now.
I'm sure Anthony realized the point I was making about the movie
"Dodgeball" as that is where the "I just threw up in my mouth a
little bit" phrase originates.
And my response was in agreement with Lee, that it was humorous.
If you weren't so concerned with being a nitpicking jackass you
might have realized that -- then again... maybe not.

Signature
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Dr J R Stockton - 29 Dec 2007 23:28 GMT
In comp.lang.javascript message <fl3778$eob$1@registered.motzarella.org>
, Fri, 28 Dec 2007 11:11:16, My Pet Programmer
<anthony@mypetprogrammer.com> posted:
>That said, I have a hack I stopped using a while ago because I decided
>I didn't want to pause things for any good reason, and here you go:
[quoted text clipped - 6 lines]
> while(curDate-date < millis);
>}
Bloated code for an inappropriate algorithm. Consider unbloated :
function pause(millis) {
var stop = +new Date() + millis ;
while (+new Date() < stop) {} ;
}

Signature
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
-Lost - 28 Dec 2007 19:01 GMT
Response to gnewsgroup <gnewsgroup@gmail.com>:
> Javascript does not seem to have a sleep function. I've tried
>
[quoted text clipped - 3 lines]
>
> Any idea? Thanks.
setTimeOut is not the same thing as setTimeout.

Signature
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Doug Gunnoe - 28 Dec 2007 19:09 GMT
> On page load, is it possible to write out something to the browser
> using
[quoted text clipped - 12 lines]
>
> Any idea? Thanks.
To find out why that does not work, after the document.write, right
click and choose view source.
I'm not sure what you are trying to do, but maybe look into modifying
innerHTML instead of doing document.write.