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

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 2072

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
5
by: Ben | last post by:
hi all, just wondering if it is possible to call a function that resides on external php file before any <html> tag?? i have a code that sets a cookie which needs to be called before <html> tag....
9
by: Philip TAYLOR | last post by:
Configuring a new instance of IIS, I noticed that it allows an HTML-formatted document trailer to be appended to every document served. Unfortunately, on checking its behaviour, I find that it...
10
by: Kathy Burke | last post by:
Hi, in trying to discover why my RegisterStartUpScript wouldn't work (I do NOT see it in the HTML source), I looked at the HTML source of a page where I do an XslTransform. First, I get the...
4
by: Mark G. | last post by:
Hello. I am attempting to write a "scraper" to download information from a commercial web site. Oddly enough, they don't want to make this easy for me! Their pages include plenty of Javascript,...
1
by: yawnmoth | last post by:
I'm trying to mess around with PHP5's DOM functions and have run into something that confuses me: <?php $dom = new DOMDocument(); $dom->loadHTML('<html></html>'); echo...
1
by: John | last post by:
Hi var poster="<html><head..... etc .... </html>"; var animal='dog'; The string contains images and text that changes. Originally I wanted to do something like print "<a href=" +...
3
by: Silmaril | last post by:
hi everyone, i have a question about place of metatags. i've started to seo for active webpage of our client(which is not coded by me) ,but website is very bad coded then i'm a lazy programmer...
3
by: gaya3 | last post by:
Hi, can anyone please say me how to add <html> tags inside JTextarea? Thanks in Advance. -Thanks & Regards, Hamsa
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.