Including script in HTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Berry B

    Including script in HTML

    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="JavaS cript" src="menu.js"></script>

    And in the body i've put the following:

    <BODY bgcolor="#00000 0" marginwirgin: 0" onLoad="printMe nu()"
    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

    #2
    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.n tnu.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="JavaS cript" src="menu.js"></script>
    >
    > And in the body i've put the following:
    >
    > <BODY bgcolor="#00000 0" marginwirgin: 0" onLoad="printMe nu()"
    > 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]


    Comment

    • Berry B

      #3
      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@ver izon.net> wrote in message
      news:fIYXb.1508 8$5W3.13541@nwr ddc02.gnilink.n et...[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.n tnu.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="JavaS cript" src="menu.js"></script>
      > >
      > > And in the body i've put the following:
      > >
      > > <BODY bgcolor="#00000 0" marginwirgin: 0" onLoad="printMe nu()"
      > > 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]


      Comment

      • Ivo

        #4
        Re: Including script in HTML

        "Berry B" <dagerik@stud.n tnu.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="JavaS cript" src="menu.js"></script>
        > <BODY bgcolor="#00000 0" marginwirgin: 0" onLoad="printMe nu()"
        > 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="JavaS cript" type="text/javascript" src="menu.js"></script>
        <BODY bgcolor="#00000 0" marginwidth="0" marginheight="0 "
        onLoad="printMe nu();" onResize="dth=' 0';">


        Comment

        • Robert

          #5
          Re: Including script in HTML

          In article <40312f39$1@new s.broadpark.no> ,
          "Berry B" <dagerik@stud.n tnu.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>clientqu esta</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('fr om point 1.');">

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

          </BODY>

          </HTML>

          Comment

          Working...