javascript outside of <html> tags

T

taras.di

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
 
M

Martin Honnen

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.
 
T

Thomas 'PointedEars' Lahn

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top