468,507 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,507 developers. It's quick & easy.

javascript outside of <html> tags

Hi everyone,

Is it possible to place javascript outside of <html> tags? I'm trying
it on mozilla atm, and it seems to be working, but I was more worried
about the older browsers.

Cheers

Taras

Dec 19 '05 #1
2 1900

ta******@gmail.com wrote:
Is it possible to place javascript outside of <html> tags? I'm trying
it on mozilla atm, and it seems to be working, but I was more worried
about the older browsers.


Well Firefox 1.5 for instance supports SVG and script and there you
could certainly place script inside of an SVG document "completely
outside of any HTML elements".

If you want to write HTML tag soup ignoring specified HTML standards
respectively DTDs then you can do that if you serve the contents as
text/html, browsers usually try to make sense of that with their "tag
soup" parsers but results can vary. In the end the browser (at least the
modern one) has to built a document object model where the document node
has to have exactly one element child node, the html element node, and
all other element nodes have to be descendants of that html element
node. So any tag soup alike e.g.

<script>
document.write('<p>Kibology for all.');
</script>
<html>
<head>
<title>example</title>
</head>
<body>
</body>
</html>

forces the browser to guess where to place the script element and the p
element it writes in the DOM tree.

But text/html has a long history being used for tag soup and browsers
(older and newer) usually deal with that without complaints.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 19 '05 #2
ta******@gmail.com wrote:
Is it possible to place javascript outside of <html> tags?
Script code does not need to be placed within a HTML document, if
you mean that.

The `script' element must be child of the `head' or `body' element,
hence the `html' element must be its ancestor (its grandparent, if
you will), if you mean that.
I'm trying it on mozilla atm, ^^^
Is that

,-[FOLDOC]
|
| 3. <chat> At the moment.

?

Otherwise, please explain.
and it seems to be working, but I was more worried about
the older browsers.


It is not a question of "older browsers", it is a question
of interoperable code, which non-Valid markup is not.

<URL:http://validator.w3.org/>
PointedEars
Dec 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by josh dismukes | last post: by
5 posts views Thread by Ben | last post: by
4 posts views Thread by Mark G. | last post: by
3 posts views Thread by gaya3 | last post: by
reply views Thread by NPC403 | last post: by
3 posts views Thread by gieforce | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.