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