473,387 Members | 1,575 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.

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

Similar topics

2
by: Nat | last post by:
Hi there, I have code as following but it returns error Error Type: Microsoft VBScript compilation (0x800A03F6) Expected 'End' /urbisjhdintranet/metadata/resultList.asp, line 324 which is the...
2
by: David Pautler | last post by:
I'm creating a web-based authoring tool where one form encompasses several sections for editing. I'd like each section to have its own reset button, so that use of that button affects only that...
9
by: ALuPin | last post by:
Hi newsgroup users, I have the following java-script: </SCRIPT> </head> <body text='' link='' vlink='' alink='' bgcolor='FFFFFF'> <p> <center><TABLE cellSpacing=1 cellPadding=1...
2
by: Matthew Crouch | last post by:
Sorry, more dumb newb questions. I've got part of a page that seems to be rendering just fine. It's built by: function writeTabPanel(){ var tpText = ''; tpText += '<div id="'; tpText +=...
13
by: tshad | last post by:
I have some nested DataGrids in my Datalist. There could be 20 datalist items. If I scroll down to the 18th item and expand it to show the DataGrid, the page always goes back to the beginning...
10
by: Iain | last post by:
Hi All My apologies if this appears to be simple to some of you but I have very little experience of javascript and I cannot work this one out, The code below is a nice piece of code I found...
2
by: Mr. T | last post by:
Hi, i have a master page, and then my aspx page that uses that master page. Now in my aspx i want to use a LinkButton to sort data on my page. My question is where do i put the sub the...
2
by: gareth182 | last post by:
Hello all. I am a complete noob to Javascript, but I do have a good knowledge of HTML & CSS. I need someone to tell me if the following issue can be achieved using Javascript, I will explain in...
2
by: Reggie | last post by:
Hi and TIA! I have a class file located in my root directory with all me web pages. I call/use the class and it works fine. I have no imports statements aspx or codebehind. My question is why? ...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.