|
From: howachen on 19 Feb 2006 00:28 Hi Some examples use the following codes in order to load external JS... e.g. document.write("<scr"+"ipt language=javascript .... I have one qusestion, Why need to separate the "script" into "<scr"+"ipt ...? Many people are using this way but i really don't know why... Thanks. howa
From: Thomas 'PointedEars' Lahn on 19 Feb 2006 07:22 howachen(a)gmail.com wrote: > Some examples use the following codes in order to load external JS... > > e.g. > > document.write("<scr"+"ipt language=javascript .... > > I have one qusestion, > > Why need to separate the "script" into "<scr"+"ipt ...? > > Many people are using this way but i really don't know why... Because those people lack a minimum clue about what they are doing. Using the `language' attribute, often instead of the required `type' attribute, is another indication of that. It is not at all necessary to do the above. It might have been an attempt at working around the Netscape 4.x Run-Length Bug (NRLB), but since this is rather a heisenbug, it is not a reliable approach. This code is probably based on the common misconception that "</scr" + "ipt" would prevent a markup parser from accidentally recognizing the end tag of a dynamically generated `script' element as the end tag of the generating `script' element, and therefore the start tag of a dynamically generated `script' element as the start tag of a generating `script' element. In fact, the latter is unnecessary and the former only works for tag soup parsers that recognize `</script>' as end of `script' element content. A standards compliant parser recognizes the ETAGO delimiter (`</') as the end of the `script' element's CDATA content. Therefore, the reasonable approach is to write "<\/script>" instead of "</script>" within the HTML `script' element (that goes for other generated end tags as well). And so far, there is no known (tag soup) parser that recognizes `<script' within the `script' element as the start tag of a generating `script' element before it is generated. PointedEars
From: d on 20 Feb 2006 06:16 <howachen(a)gmail.com> wrote in message news:1140326933.805951.3160(a)f14g2000cwb.googlegroups.com... > Hi > > Some examples use the following codes in order to load external JS... > > e.g. > > document.write("<scr"+"ipt language=javascript .... > > I have one qusestion, > > Why need to separate the "script" into "<scr"+"ipt ...? > > Many people are using this way but i really don't know why... Because some browsers would, back in the day at least, throw up errors if there was a script tag in a block of javascript. I worked at an advertising agency that had libraries of JS to get round such limitations... Whether that's still the case is unknown to me :) > > Thanks. > > > howa >
From: Evertjan. on 20 Feb 2006 06:22 d wrote on 20 feb 2006 in comp.lang.javascript: >> Many people are using this way but i really don't know why... > > Because some browsers would, back in the day at least, throw up errors > if there was a script tag in a block of javascript. I worked at an > advertising agency that had libraries of JS to get round such > limitations... Whether that's still the case is unknown to me :) > You don't know if you are still working there? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
From: Richard Cornford on 20 Feb 2006 10:29 d wrote: > <howachen(a)gmail.com> wrote: >> Some examples use the following codes in order to load external JS... >> >> e.g. >> >> document.write("<scr"+"ipt language=javascript .... >> >> I have one qusestion, >> >> Why need to separate the "script" into "<scr"+"ipt ...? >> >> Many people are using this way but i really don't know why... > > Because some browsers would, back in the day at least, throw > up errors if there was a script tag in a block of javascript. <snip> All (at least SCRIPT element understanding) browsers have had problems with </SCRIPT> tags, at least their HTML parsers have as they have no choice but consider occurrences of </SCRIPT> that follow an opening SCRIPT tag as terminating the script element (HTML parsers cannot see that such occurrences within javascript strings are not meant for their attention). However, I have never encountered a browser that knew what a SCRIPT element was and had a problem with opening script tags within javascript strings. Can you name one that does? The breaking up of SCRIPT tags in strings follows from a misidentification of a real issue and was introduced and propagated because it deals with the real practical issue as a side effect and is harmless otherwise (much like most eval abuse 'works' and is harmless otherwise, i.e. the inefficient alternative to an objectively superior option). It is, was, and always will be, an old wives tale that 'works' (in the broadest sense) and keeps people from seeing the real cause of the problem and so addressing the real issue. It is what is known as 'programming by coincidence'; always popular among the masses who script web pages. Richard.
|
Pages: 1 Prev: scrolling tables Next: XMLHttpRequest using multipart/form-data |