473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript1.2">

var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getEle mentById("text" ).style.color=" rgb("+hex+","+h ex
+","+hex+")" ;
setTimeout("Fad eText()",20);
}
else
{
hex=240;
}
}
</script>
I have a <divwith an id of "text"...ag ain, 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 2259
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="JavaS cript1.2">
Just write javascript.
var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getEle mentById("text" ).style.color=" rgb("+hex+","+h ex
+","+hex+")" ;
setTimeout("Fad eText()",20);
}
else
{
hex=240;
}
}
</script>

I have a <divwith an id of "text"...ag ain, 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...@ka tur.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="JavaS cript1.2">
....type="text/javascript".... language is neither needed, nor standard
compliant.
var hex=240;

function FadePage()
{
if (hex>0)
{
hex-=11;
document.getEle mentById("text" ).style.color=" rgb("+hex+","+h ex
+","+hex+")" ;
setTimeout("Fad eText()",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...@ka tur.dewrote:
>><script language="JavaS cript1.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="JavaS cript"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="JavaS cript"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...@gregork ofler.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="JavaS cript1.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...re minds me of how Microsoft
moves things around in MS Word, etc.
var hex=240;
function FadePage()
{
if (hex>0)
{
hex-=11;
document.getEle mentById("text" ).style.color=" rgb("+hex+","+h ex
+","+hex+")" ;
setTimeout("Fad eText()",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...@ka tur.dewrote:
>

I said, that you should not specify the javascript version in this tag.
<script language="JavaS cript"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
"applicatio n/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="JavaS cript1.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.de mon.co.uk>
Jun 27 '08 #9

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

Similar topics

2
1495
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 (i.e. successfully executing window.open() in Mozilla 1.5; however, I've observed it to work a few times in IE 6.0 and Opera 5.something. It does not seem to be a timing thing -- if I re-call the function somewhat later using setTimeout it still...
1
3065
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 place them in the <body> tag? Thanks.
9
19159
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 certain pages execute my function() onLoad? The function basically just sets the original values of fields so that I can determine if a field has been changed or not, which aleviates unnec. sql update on the backend..
9
7169
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
1825
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
2241
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 HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=utf-8">
6
2547
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. This PHP code works: the HTML file with added comments displays correctly in my browser. However, appending text to the very end of the HTML file creates what is, strictly speaking, invalid code. I am looking for a way to tell PHP to write data to...
8
3037
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 seems to manifest itself initially when you mouse over the "Choose a different route >>" link (which has onmouseover event to change font styles). It seems that having two functions in the onload command of the <body> tag is causing the map to...
5
1814
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 want to do it this way so I can place it in my base .js file for inclusion in all apps I write without having to reinvent the wheel each time. My problem is this; the <body> tag does not seem to pass the "id" value but rather the name of the...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7475
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.