473,324 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

PageFade() with onLoad in <body> Good, with onClick in <a href> Bad??


Another weekend, another project, another problem....

Why should a perfectly fine function work only half-way through when
called through onClick in an anchor tag??

The text fade-in script below works when called through onLoad in the
<bodytag, but it "hangs" when called through onClick in <a
href="#">, as follows:

<script language="JavaScript1.2">

var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getElementById("text").style.color="rgb(" +hex+","+hex
+","+hex+")";
setTimeout("FadeText()",20);
}
else
{
hex=240;
}
}
</script>
I have a <divwith an id of "text"...again, it all fades in fine when
called through onLoad in the <bodytag but seems to stall at
setTimeout(...) -- maybe it doesn't even get to it at all; the text
just fades in half-way and stays that way, never completing the fade-
in process.

Now why should that be??
TIA!!
Jun 27 '08 #1
8 2227
Prisoner at War schrieb am 26.04.2008 18:55:
Another weekend, another project, another problem....

Why should a perfectly fine function work only half-way through when
called through onClick in an anchor tag??

The text fade-in script below works when called through onLoad in the
<bodytag, but it "hangs" when called through onClick in <a
href="#">, as follows:

<script language="JavaScript1.2">
Just write javascript.
var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getElementById("text").style.color="rgb(" +hex+","+hex
+","+hex+")";
setTimeout("FadeText()",20);
}
else
{
hex=240;
}
}
</script>

I have a <divwith an id of "text"...again, it all fades in fine when
called through onLoad in the <bodytag but seems to stall at
setTimeout(...) -- maybe it doesn't even get to it at all; the text
Test this with alerts before and after the style.color rule.
just fades in half-way and stays that way, never completing the fade-
in process.

Now why should that be??
Wich Browser showed this problem?

--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #2
On Apr 26, 3:27 pm, Holger Jeromin <news03_2...@katur.dewrote:
>

Just write javascript.
I dunno, I've always like useless little details like that!
Test this with alerts before and after the style.color rule.
Hmmm, okay, what do you suspect? If an alert() comes up, before or
after, what of it?
Wich Browser showed this problem?
Well, actually, now that you ask...Opera 9 and IE 7 just ignore the
whole thing and display the page, without any fading-in effect...FF 2
is what gets "stalled" like half-way through....
--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #3
Prisoner at War meinte:
Another weekend, another project, another problem....

Why should a perfectly fine function work only half-way through when
called through onClick in an anchor tag??

The text fade-in script below works when called through onLoad in the
<bodytag, but it "hangs" when called through onClick in <a
href="#">, as follows:

<script language="JavaScript1.2">
....type="text/javascript".... language is neither needed, nor standard
compliant.
var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getElementById("text").style.color="rgb(" +hex+","+hex
+","+hex+")";
setTimeout("FadeText()",20);
What or where is "FadeText()"? Or did you mean FadePage()?

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #4
Prisoner at War schrieb am 27.04.2008 00:43:
On Apr 26, 3:27 pm, Holger Jeromin <news03_2...@katur.dewrote:
>><script language="JavaScript1.2">
Just write javascript.
I dunno, I've always like useless little details like that!
I said, that you should not specify the javascript version in this tag.
<script language="JavaScript"is better.
>Test this with alerts before and after the style.color rule.
Hmmm, okay, what do you suspect? If an alert() comes up, before or
after, what of it?
you said, that you have no idea, if the browser reaches this point of
your code. You can test this with a few alerts...

--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #5
Holger Jeromin meinte:
I said, that you should not specify the javascript version in this tag.
<script language="JavaScript"is better.
Why? This attribute is deprecated and useless (unless you are writing
for some browsers of ancient times). However, if you want valid markup
you have to provide a type attribute. [1]

Gregor
[1] <http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1>

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #6
On Apr 26, 6:44 pm, Gregor Kofler <use...@gregorkofler.atwrote:
Prisoner at War meinte:
Another weekend, another project, another problem....
Why should a perfectly fine function work only half-way through when
called through onClick in an anchor tag??
The text fade-in script below works when called through onLoad in the
<bodytag, but it "hangs" when called through onClick in <a
href="#">, as follows:
<script language="JavaScript1.2">

...type="text/javascript".... language is neither needed, nor standard
compliant.
I see that now! Goodness, why all this messing around all the time
with depreciating tags and attributes...reminds me of how Microsoft
moves things around in MS Word, etc.
var hex=240;
function FadePage()
{
if (hex>0)
{
hex-=11;
document.getElementById("text").style.color="rgb(" +hex+","+hex
+","+hex+")";
setTimeout("FadeText()",20);

What or where is "FadeText()"? Or did you mean FadePage()?
Yes, you are correct: I meant "FadePage ()" -- "FadeText()" is just
another name; sorry for the confusion!
<SNIP>
Jun 27 '08 #7
On Apr 27, 4:23 pm, Holger Jeromin <news03_2...@katur.dewrote:
>

I said, that you should not specify the javascript version in this tag.
<script language="JavaScript"is better.
I know, I know: W3C standards compliance. I wonder why they keep
changing these standards, though. Now "type" is the preferred
attribute -- and instead of "text/JavaScript" they will want
"application/JavaScript" next!
you said, that you have no idea, if the browser reaches this point of
your code. You can test this with a few alerts...
Yes, but then what...I mean, what if it never reaches that point in
the code, and what if it does? What would it mean -- why would
reaching or not reaching that point cause the effect?

I'm trying to figure out what the FF2 browser is "thinking" WRT that
code...IE7 and Opera 9 seem to totally ignore it. Is the code itself
wrong? Why does it work onLoad in the <bodytag but not onClick in
an <a hrefanchor tag??
--
Mit freundlichen Grüßen
Holger Jeromin
Jun 27 '08 #8
Gregor Kofler wrote:
Prisoner at War meinte:
><script language="JavaScript1.2">

...type="text/javascript".... language is neither needed,
Correct.
nor standard compliant.
Wrogn. The `language' attribute of the `script' element is specified in the
Web standards HTML 4.01 Transitional [1], and XHTML 1.0 Transitional [2].

It is not specified in the Web standard HTML 3.2 as the `script' element has
no attributes there.[3] It is not specified in the Web standards HTML 4.01
Strict [4], and XHTML 1.0 Strict [5], because it is *deprecated* for obvious
reasons.[6] (JFTR, the `script' element is not specified in ISO/IEC
15445:200(E) at all.[6])
PointedEars
___________
[1] http://www.w3.org/TR/1999/REC-html40.../loosedtd.html
[2]
http://www.w3.org/TR/2002/REC-xhtml1...0-Transitional
[3] http://www.w3.org/TR/REC-html32
[4] http://www.w3.org/TR/1999/REC-html40...strictdtd.html
[5]
http://www.w3.org/TR/2002/REC-xhtml1...TML-1.0-Strict
[6]
http://www.w3.org/TR/1999/REC-html40....html#h-18.2.1
[7] https://www.cs.tcd.ie/15445/TC1.html
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #9

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

Similar topics

2
by: Starry Gordon | last post by:
I've been running some small test programs which seem to indicate something noticed in a larger script, that a function called from onLoad() in the <body> tag will not succeed in creating a window...
1
by: Dung Ping | last post by:
For instance, one set is: <body onload="blinking_header()" onunload="stoptimer()"> Another set is: <body onload="writemsg()" onunload="stoptimer()"> They represent two functions. How to...
9
by: bmgz | last post by:
I need to execute a JavaScript function "onload". The only problem is I don not have access to the <body> tag as it is a part of the standard page-header include (a separate file). How could I have...
9
by: tomcadman | last post by:
Using Javascript, how do I give focus to a form text box on page load without using the <body> tag? Thanks!
2
mickey0
by: mickey0 | last post by:
HI, is it possible to do this? I'd like at first execute the ONE and then the TWO. Will it work? <body onload="func1()","func2()"> </body>
23
by: Xah | last post by:
Here's a interesting case of invalid html 4 strict file. In summary, if you have <body></bodywithout any content, the file would be invalid under html 4 strict. Valid if html 4 lose. <!DOCTYPE...
6
by: Shawn | last post by:
Hello: I have the following code in a PHP file. An HTML form passes user comment data to the PHP, which then appends the user comments to the end of the HTML file on which the form is located....
8
by: flydev | last post by:
Hello, Thanks for taking the time to help. I'm having a problem with GMap and IE7 (could be occurring in earlier versions). First let me give you a link to the problem: problem The problem...
5
Claus Mygind
by: Claus Mygind | last post by:
I want to dynamically add a hidden <div> </div> to a document when loading my page. It is kind of a generic scratch pad into which I can load messages and data I may want to display to the user. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.