473,378 Members | 1,492 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,378 software developers and data experts.

Load external JS using Javascript...

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

Feb 19 '06 #1
4 1680
ho******@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
Feb 19 '06 #2
d
<ho******@gmail.com> wrote in message
news:11********************@f14g2000cwb.googlegrou ps.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

Feb 20 '06 #3
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)
Feb 20 '06 #4
d wrote:
<ho******@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.
Feb 20 '06 #5

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

Similar topics

3
by: Francois | last post by:
Is it possible to automatically create an array on load page? I want my script to be external. (<script language="JavaScript" src="somescript.js"></script>) Several pages should use this...
2
by: Mark Anderson | last post by:
Problem in short: user is moving (clicking a link) from my page before some JS code is run (to write a cookie). The code does not run (in Body's onLoad event) until the page loads as there are a...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
6
by: jeet_sen | last post by:
Hi, I have a file containing variables defined in javascript syntax, like, var a = 15; var list = ; .. .. I want to load this external file dynamically and read in the data. I can successfuly...
4
by: ReGenesis0 | last post by:
Okay, this involves integrating javascript with PHP (though you don't have to know PHP to understand my question.) I have a page. It has a link. When someoen clicks on the link, iw ant to...
2
by: Jeff Allan | last post by:
Hello, I am trying to load an external HTML page into a DIV tag with .NET 05 and I can't figure it out. Any suggestions? My Scenario: - Gridview populated with list of available files - I...
1
by: charlie imac | last post by:
I have a question on the capability of Ajax. My question is: Is it possible to dynamically load any of the javascript gallery programs such as: Adobe Spry Gallery SmoothGallery others I...
4
daJunkCollector
by: daJunkCollector | last post by:
I am using AJAX to dynamically load content into a <div> layer. As it stands, I am loading .html's into the <div> layer and it works awesome. The problem is that when I try to replace the .html...
1
by: ahmh | last post by:
The javascript function is called getsportart2 in the codebehind page_load I have the following Page.RegisterStartupScript("MyScript3","<script type='text/javascript'...
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: 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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.