468,136 Members | 1,471 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

where to place the javascript in html page

Hi,

I m getting annoying display problem when placing javascript tags in a
html page. Should the javasscript tags placed at the beginning of a
html page before anything start? or placed between the <head></head>
tags? If I placed the script tags at the beginning of the html page, I
can have the Draggale Layer shown and movable by the mouse, but the
entired page will not read the style.css file (as I found the font
displayed very ugly); If I placed the script tags between the <head>
</head> tags, the Draggable Layer is movable, but the font are displayed
correctly.

eg.

<script language="JavaScript1.2">
Draw draggle layer...
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Eveready</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
....
</body>

The above java script placed at the start of the html page will make the
Draggable Layer moving fine, but the rest of the font dispalyed very ugly.

Thanks
A
Mar 15 '06 #1
5 2051
Hi,

I just found the following offending code causes the Draggable Layer not
moving:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

where should I place the above code in my html page?
I need to have that for a correct display of the font. But having it
will cause the box not movable. Without it, font is not display correctly.

A

acord wrote:
Hi,

I m getting annoying display problem when placing javascript tags in a
html page. Should the javasscript tags placed at the beginning of a
html page before anything start? or placed between the <head></head>
tags? If I placed the script tags at the beginning of the html page, I
can have the Draggale Layer shown and movable by the mouse, but the
entired page will not read the style.css file (as I found the font
displayed very ugly); If I placed the script tags between the <head>
</head> tags, the Draggable Layer is movable, but the font are displayed
correctly.

eg.

<script language="JavaScript1.2">
Draw draggle layer...
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Eveready</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
...
</body>

The above java script placed at the start of the html page will make the
Draggable Layer moving fine, but the rest of the font dispalyed very ugly.

Thanks
A

Mar 15 '06 #2

acord wrote:
where should I place the above code in my html page?
I need to have that for a correct display of the font. But having it
will cause the box not movable. Without it, font is not display correctly.


It would be a good thing to post as much as possible simplified example
that can reproduce problem.

Mar 15 '06 #3
"acord" <ac***@telpacific.com.au> wrote in message
news:44********@news.rivernet.com.au...
Hi,

I m getting annoying display problem when placing javascript tags in
a html page. Should the javasscript tags placed at the beginning of
a html page before anything start? or placed between the
<head></head> tags? If I placed the script tags at the beginning of
the html page, I can have the Draggale Layer shown and movable by
the mouse, but the entired page will not read the style.css file (as
I found the font displayed very ugly); If I placed the script tags
between the <head> </head> tags, the Draggable Layer is movable, but
the font are displayed correctly.

eg.

<script language="JavaScript1.2">
Draw draggle layer...
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Eveready</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
...
</body>

The above java script placed at the start of the html page will make
the Draggable Layer moving fine, but the rest of the font dispalyed
very ugly.

The doctype declaration must be the first line in the document.

Where the script element goes depends on what's in the script and how
it's triggered. It must go in either the head or the body. We can't
tell you more without more information about the script.

David
Stardate 6203.1
Mar 15 '06 #4
acord said on 16/03/2006 12:19 AM AEST:
Hi,

I just found the following offending code causes the Draggable Layer not
moving:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

where should I place the above code in my html page?
The doctype affects features within the page. It must appear as the
first thing, before any HTML.

Don't use such an old doctype unless you have a very good reason, use a
strict doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

I need to have that for a correct display of the font. But having it
will cause the box not movable. Without it, font is not display correctly.


You are (probably) seeing the effect of the doctype - removing it causes
the browser to go into 'quirks mode' and anything is possible. *Always*
use a doctype.

<URL:http://www.quirksmode.org/css/quirksmode.html>
[...]
I m getting annoying display problem when placing javascript tags in a
html page.
Script elements, of themselves, have no effect at all on display. Their
content might. Moving them to produce invalid HTML is not catered for
in specification.

Don't futz around until 'something works', find out why it's going wrong
and fix the problem at the source. Asking your question here was a good
start.

Should the javasscript tags placed at the beginning of a
html page before anything start? or placed between the <head></head>
tags?
Script elements can be placed anywhere in the head or body of a
document, the tags must be properly nested.

If I placed the script tags at the beginning of the html page, I
can have the Draggale Layer shown and movable by the mouse, but the
entired page will not read the style.css file (as I found the font
displayed very ugly); If I placed the script tags between the <head>
</head> tags, the Draggable Layer is movable, but the font are
displayed correctly.
You are seeing the results of the browser's attempts at error correction
of your invalid HTML - garbage in, garbage out.

eg.

<script language="JavaScript1.2">
Do not use the language attribute - especially that one. Use type as
it's required:

<script type="text/javascript">
Draw draggle layer...
</script>
The script element can't appear before the doctype, or the opening HTML
or HEAD tags (if present).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Eveready</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
...
</body>

The above java script placed at the start of the html page will make
the Draggable Layer moving fine, but the rest of the font dispalyed
very ugly.


Who knows what effect invalid HTML should have on a web page? Start
with a strict DTD and valid HTML and go from there.

<URL:http://validator.w3.org/>
--
Rob
Mar 16 '06 #5
RobG wrote:
acord said on 16/03/2006 12:19 AM AEST:
I just found the following offending code causes the Draggable Layer not
moving:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

where should I place the above code in my html page?


The doctype affects features within the page. It must appear as the
first thing, before any HTML.


s/doctype/DOCTYPE declaration/
s/any/any other/
s/\.$/ to trigger DOCTYPE switching./
PointedEars
Mar 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Nat | last post: by
9 posts views Thread by ALuPin | last post: by
2 posts views Thread by Matthew Crouch | last post: by
13 posts views Thread by tshad | last post: by
2 posts views Thread by Mr. T | last post: by
2 posts views Thread by Reggie | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.