472,983 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 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 2291
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? ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.