Very thanks Michel for your detailed response.
You're welcome.
Im very surprised about the amount of things that have changed in plane
HTML and JavaScript...
The points I made about nesting elements incorrectly have always held
true. Browsers will render them still, but the browser will have to
correct its internal representation to something more acceptable. The
problem with this, apart from making parsing slower, is that every browser
corrects documents differently. They may also "correct" it in such a way
that it breaks your page.
A recent example appeared in comp.infosystems.
www.authoring.html (ciwah).
The poster had something along the lines of:
<div>
<form ...>
[form controls]
</div>
<div>
<div>
[form controls]
</form>
</div>
<div>
<form ...>
[form controls]
</form>
</div>
</div>
Aside from the fact that it's "DIV soup", it's complete nonsense,
structurally. The first FORM begins in one DIV, ends in another. It would
be difficult for a user agent to correct that and keep its original
functionality.
For example: the label <b> deprecated!!!! :-S
Sorry, I was wrong there. The B element isn't deprecated, but it is
discouraged in favour of style sheets. See
<URL:
http://www.w3.org/TR/html4/present/graphics.html#h-15.2>.
In general, any element or attribute that is purely presentational, such
as FONT and bgcolor, have been deprecated. After all, the intent of HTML
is not a means of presentation, but a way of describing what parts of
document actually are - what they mean.
I have already tested your script and it works perfectly, but i don't
understand it a lot :-(
I have a tendency to be terse.
/* This function will modify the inline style sheet information
* for the given element. Specifically, it will set the font
* weight to the given value.
*
* The result is the equivalent of applying the attribute,
* style="font-weight: <value>;" to the element.
*/
function setWeight(element, value) {
/* First, we should check that the object reference to the
* element is a valid reference. Objects, other than null,
* evaluate to true when converted to a boolean.
*
* Second, we should check that the object supports the style
* object - our way of modifying its inline style information.
*/
if(element && element.style) {
/* If the previous tests pass, we can assign a new value. */
element.style.fontWeight = value;
}
}
Now notice the values passed to the function:
onmouseover="setWeight(this, 'bold');"
onmouseout="setWeight(this, '');"
The value, 'bold', will quite obviously set the font weight to bold, but
what about the empty string? This effectively removes any styling for that
property. With that gone, the element will revert to whatever style is
specified by the page style sheet.
I see i have to start studying HTML
It's mainly a matter of realising that HTML has rules. Many of them are
common sense, like a nested element should be completely contained
<form>
<div>
</div>
</form>
not
<form>
<div>
</form>
</div>
and that certain elements may only contain certain other elements.
Learning this is just a matter of time. Regularly validating your pages
(using the link I gave in my last post) should give you a feel for what's
correct, and what's not.
Due to error correction in browsers, it seems that many people think you
can write any old rubbish and everything will work perfectly. Whilst what
an author has written may be fine for a particular browser, they often
haven't tested it on many other browsers where their page will go horribly
wrong. A lot of people still think that IE and Netscape are the only
browsers in the world. Some only know the former exists.
Javascript, the language, hasn't changed that much. It's the document
object model (DOM) that browsers expose to scripts that has come a long
way.
The documentation of HTML, JavaScript and DHTML that i have is from 1998
That is quite out-of-date, though HTML 4.01 (the most recent version) only
became a Recommendation in '99.
(i don't attach it because it is 3 megas, but i can send to you if you
want).
If you had attached it, my news server would have rejected your post
entirely. It was a good thing you didn't.
You should never send attachments, which includes sending HTML-based
messages, to Usenet (unless you're posting to a binary group).
Anyway, may be if i use your suggestions the web could not work in old
versions of Explorer or Netscape.
According to Microsoft, that code should work in IE 4, but I can't test
that. As for NN 4, very little will work there. A growing opinion is that
NN 4 is dead and attempting to support it is a wasted effort.
[snip]
As far as resources go, I'm not really the person to ask.
The FAQ for this group (<URL:
http://jibbering.com/faq/>) contains some
links, and plenty of its own advice with regard to Javascript.
As for HTML, try <URL:
http://www.html-faq.com/>, and
<URL:
http://www.htmlhelp.com/> seems to come better recommended than
<URL:
http://www.w3schools.com/>.
Mike