Re: Why people use this style of javascript declaration?




but since there is no content inside the tag anyway, what are the
reason behind this style?

If you want to question the reasons of those who
defined those rules then you might want to try your luck in
comp.infosystems.www.authoring.html.

I say this question more relevant to JavaScript rather then to the HTML
tags as such.

The reason is historical (as many things in HTML/scripting).

Until versions NN3/IE3 the only browser with JavaScript support was
Netscape 2.x, and it did not support external .js files, only scripts
directly inserted into page between <script>...</script> tags.
Respectively <script> tag was added to HTML specs as the one requiring
closing tag.
With versions NN3/IE3 it became possible to use external .js files, but
the paired tag was used as the fall-back option for NN2 users. If both
src attribute and inline content were provided, NN3/IE3 users would get
the external .js file executed and inline content ignored. NN2 users
would get src ignored and inline block executed:

<script language="JavaScript" src="external.js">
window.alert("Your browser doesn't support external scripts");
</script>

(btw it is another FAQ when people are trying to combine both external
and inline scripts in one tag and getting only the external script
executed. If you ever tried it and wondered why then here is the
answer).

By NN4/IE4 the above became a standard with a bunch of legacy scripts
around, so it was too late to change anything.

Hope it helps.

.



Relevant Pages

  • Re: automake, autoconf compiling
    ... scripts are indeed very platform independent. ... > reason why the FreeBSD ports infrastructure needs to play so many ... the reason the Ports go through all the hoops you see is that they ... One other reason is, of course, the fact that the autotools have changed ...
    (freebsd-newbies)
  • Re: automake, autoconf compiling
    ... scripts are indeed very platform independent. ... > reason why the FreeBSD ports infrastructure needs to play so many ... the reason the Ports go through all the hoops you see is that they ... One other reason is, of course, the fact that the autotools have changed ...
    (freebsd-questions)
  • RE: WMP11 RAM usage issue
    ... Manager and found out that WMP was using upwards of 225MBs of RAM, ... I can't see any reason for it to have started ... ID3V2.3 but it reads ID3V2.2 tags, such as those from iTunes, just fine. ... was the tab) to choose which tag version you want to use. ...
    (microsoft.public.windowsmedia.player)
  • Re: *Solved* Why doesnt this page display anything in IE6?
    ... short tag for, and instead requires that the end tag be ... is for these platforms and if this is your only audience then code for those ... renders but scripts broken in Opera ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: AK discussion hand - part 1
    ... TAG, I'm reluctant to fold. ... Flatting here is setting myself up to give up on many flops, ... some reason I felt he wasn't folding pre-flop here. ...
    (rec.gambling.poker)