Connecting Tech Pros Worldwide Forums | Help | Site Map

Including script in HTML

Berry B
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi!
I'm extremely new to JavaScript programming, so bear with me pleace.
I'm having trouble including a script into a page from an external .js file.
I've put the following in the head;

<script language="JavaScript" src="menu.js"></script>

And in the body i've put the following:

<BODY bgcolor="#000000" marginwirgin: 0" onLoad="printMenu()"
onResize=dth="0" marginheight="0" style="ma"if (isNS4) nsResizeHandler()">

The problem is that the function printMenu doesn't run, I just keep getting
runtime errors in IE, and the menu buttons will not show. Any suggestions?

Tnx!


JCO
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Including script in HTML


Can we assume that you have the function "printMenu()" in menu.js?
If so, is menu.js at the root or in a folder?
If in a folder, you need to add the folder path, i.e....
"my_scripts/menu.js"



"Berry B" <dagerik@stud.ntnu.no> wrote in message
news:40300fcd$1@news.broadpark.no...[color=blue]
> Hi!
> I'm extremely new to JavaScript programming, so bear with me pleace.
> I'm having trouble including a script into a page from an external .js[/color]
file.[color=blue]
> I've put the following in the head;
>
> <script language="JavaScript" src="menu.js"></script>
>
> And in the body i've put the following:
>
> <BODY bgcolor="#000000" marginwirgin: 0" onLoad="printMenu()"
> onResize=dth="0" marginheight="0" style="ma"if (isNS4) nsResizeHandler()">
>
> The problem is that the function printMenu doesn't run, I just keep[/color]
getting[color=blue]
> runtime errors in IE, and the menu buttons will not show. Any suggestions?
>
> Tnx!
>
>[/color]


Berry B
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Including script in HTML



Yes, the function is in menu.js, and menu.js lies in the root folder. Are
there any other ways to include the script in the head of the page? Any
other ways to call a function in the body tag?
I would be very glad if someone posted an example!

Dag Erik

" JCO" <J.Oliviero@verizon.net> wrote in message
news:fIYXb.15088$5W3.13541@nwrddc02.gnilink.net...[color=blue]
> Can we assume that you have the function "printMenu()" in menu.js?
> If so, is menu.js at the root or in a folder?
> If in a folder, you need to add the folder path, i.e....
> "my_scripts/menu.js"
>
>
>
> "Berry B" <dagerik@stud.ntnu.no> wrote in message
> news:40300fcd$1@news.broadpark.no...[color=green]
> > Hi!
> > I'm extremely new to JavaScript programming, so bear with me pleace.
> > I'm having trouble including a script into a page from an external .js[/color]
> file.[color=green]
> > I've put the following in the head;
> >
> > <script language="JavaScript" src="menu.js"></script>
> >
> > And in the body i've put the following:
> >
> > <BODY bgcolor="#000000" marginwirgin: 0" onLoad="printMenu()"
> > onResize=dth="0" marginheight="0" style="ma"if (isNS4)[/color][/color]
nsResizeHandler()">[color=blue][color=green]
> >
> > The problem is that the function printMenu doesn't run, I just keep[/color]
> getting[color=green]
> > runtime errors in IE, and the menu buttons will not show. Any[/color][/color]
suggestions?[color=blue][color=green]
> >
> > Tnx!
> >
> >[/color]
>
>[/color]


Ivo
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Including script in HTML


"Berry B" <dagerik@stud.ntnu.no> wrote in message
news:40300fcd$1@news.broadpark.no...[color=blue]
> Hi!
> I'm extremely new to JavaScript programming, so bear with me pleace.
> I'm having trouble including a script into a page from an external .js[/color]
file.[color=blue]
> I've put the following in the head;
>
> <script language="JavaScript" src="menu.js"></script>
> <BODY bgcolor="#000000" marginwirgin: 0" onLoad="printMenu()"
> onResize=dth="0" marginheight="0" style="ma"if (isNS4) nsResizeHandler()">[/color]

The script tag needs a type declaration these days, the language may be kept
for backward-compatibily.
The quotes around the values of the attributes in the BODY tag don't look
very balanced to me, and I have never heard of marginwirgin or "ma" as a
style property. And in the event of a resize, a variable dth gets set to the
value of 0 as a string. I hope you know what that means.
A cleaned up example:

<script language="JavaScript" type="text/javascript" src="menu.js"></script>
<BODY bgcolor="#000000" marginwidth="0" marginheight="0"
onLoad="printMenu();" onResize="dth='0';">


Robert
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Including script in HTML


In article <40312f39$1@news.broadpark.no>,
"Berry B" <dagerik@stud.ntnu.no> wrote:
[color=blue]
> Yes, the function is in menu.js, and menu.js lies in the root folder. Are
> there any other ways to include the script in the head of the page? Any
> other ways to call a function in the body tag?
> I would be very glad if someone posted an example!
>
> Dag Erik[/color]

You may put the functions at the <head> section of you HTML file.

Example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>clientquesta</TITLE>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<SCRIPT type="text/javascript">

function out(comment)
{

alert("This is a inline function " + comment );
}

</script>

</HEAD>
<BODY onload="out('from point 1.');">

<br><br>A silly alert will appear.

</BODY>

</HTML>
Closed Thread