Include in many pages

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

    Include in many pages

    Hi there,

    I have a bit of java script which I would like to include in all of my html
    pages.

    Is there an easy way to include it with a reference or something.

    I don't want to have to copy and paste the code to the top of each page as
    if I then change the code I have to go through all pages to change it.

    Any help would be appreciated.

    I don't know a great deal about javascript or html but know a fair bit about
    other programming languages.

    Thanks in advance

    --

    Jamie Allison
    Sheffield Hallam University
    Software Engineering
    Final Year


  • McKirahan

    #2
    Re: Include in many pages

    "Jamie" <jamieallison@h otmail.com> wrote in message
    news:fwvEd.337$ Bb.229@newsfe5-win.ntli.net...[color=blue]
    > Hi there,
    >
    > I have a bit of java script which I would like to include in all of my[/color]
    html[color=blue]
    > pages.
    >
    > Is there an easy way to include it with a reference or something.
    >
    > I don't want to have to copy and paste the code to the top of each page as
    > if I then change the code I have to go through all pages to change it.
    >
    > Any help would be appreciated.
    >
    > I don't know a great deal about javascript or html but know a fair bit[/color]
    about[color=blue]
    > other programming languages.
    >
    > Thanks in advance
    >
    > --
    >
    > Jamie Allison
    > Sheffield Hallam University
    > Software Engineering
    > Final Year
    >[/color]

    Place the JavaScript code in a file (e.g. "yourfile.j s") then use:

    <script type="text/javascript" src="yourfile.j s"></script>

    in the <head> section of your Web page.


    Comment

    • Jamie

      #3
      Re: Include in many pages

      I Have done this now but still not working.

      I have created a file called javacode.js and put my javascript in there.
      The file starts

      <script language="JavaS cript">
      <!--
      Javascript functions here
      //-->
      </script>

      I have then got my html page below which starts as shown. Is that the right
      place to put the script type?

      <html>
      <head>
      <title>Page Title</title>

      <meta>
      <link rel="stylesheet " type="text/css" href="main.css" >

      <script type="text/javascript" src="javacode.j s"></script>

      </head>
      <body>

      My javascript works fine if I put it directly onto the page in place of the
      one include line.

      Thanks for your help so far.

      Regards

      "McKirahan" <News@McKirahan .com> wrote in message
      news:MpednU3Idp p0C3_cRVn-sA@comcast.com. ..[color=blue]
      > "Jamie" <jamieallison@h otmail.com> wrote in message
      > news:fwvEd.337$ Bb.229@newsfe5-win.ntli.net...[color=green]
      >> Hi there,
      >>
      >> I have a bit of java script which I would like to include in all of my[/color]
      > html[color=green]
      >> pages.
      >>
      >> Is there an easy way to include it with a reference or something.
      >>
      >> I don't want to have to copy and paste the code to the top of each page
      >> as
      >> if I then change the code I have to go through all pages to change it.
      >>
      >> Any help would be appreciated.
      >>
      >> I don't know a great deal about javascript or html but know a fair bit[/color]
      > about[color=green]
      >> other programming languages.
      >>
      >> Thanks in advance
      >>
      >> --
      >>
      >> Jamie Allison
      >> Sheffield Hallam University
      >> Software Engineering
      >> Final Year
      >>[/color]
      >
      > Place the JavaScript code in a file (e.g. "yourfile.j s") then use:
      >
      > <script type="text/javascript" src="yourfile.j s"></script>
      >
      > in the <head> section of your Web page.
      >
      >[/color]


      Comment

      • Jamie

        #4
        Re: Include in many pages

        Just had a thought.

        My java code has 3 function which I call on the HTML page. Is there any
        particular way I have to call the function now it is included this way
        instead of the code directly there?

        Such as javascrips.ja/MM_swapImgResto re()

        previously just called by MM_swapImgResto re()

        Regards

        "McKirahan" <News@McKirahan .com> wrote in message
        news:MpednU3Idp p0C3_cRVn-sA@comcast.com. ..[color=blue]
        > "Jamie" <jamieallison@h otmail.com> wrote in message
        > news:fwvEd.337$ Bb.229@newsfe5-win.ntli.net...[color=green]
        >> Hi there,
        >>
        >> I have a bit of java script which I would like to include in all of my[/color]
        > html[color=green]
        >> pages.
        >>
        >> Is there an easy way to include it with a reference or something.
        >>
        >> I don't want to have to copy and paste the code to the top of each page
        >> as
        >> if I then change the code I have to go through all pages to change it.
        >>
        >> Any help would be appreciated.
        >>
        >> I don't know a great deal about javascript or html but know a fair bit[/color]
        > about[color=green]
        >> other programming languages.
        >>
        >> Thanks in advance
        >>
        >> --
        >>
        >> Jamie Allison
        >> Sheffield Hallam University
        >> Software Engineering
        >> Final Year
        >>[/color]
        >
        > Place the JavaScript code in a file (e.g. "yourfile.j s") then use:
        >
        > <script type="text/javascript" src="yourfile.j s"></script>
        >
        > in the <head> section of your Web page.
        >
        >[/color]


        Comment

        • McKirahan

          #5
          Re: Include in many pages

          "Jamie" <jamieallison@h otmail.com> wrote in message
          news:_1xEd.437$ Bb.406@newsfe5-win.ntli.net...[color=blue]
          > Just had a thought.
          >
          > My java code has 3 function which I call on the HTML page. Is there any
          > particular way I have to call the function now it is included this way
          > instead of the code directly there?
          >
          > Such as javascrips.ja/MM_swapImgResto re()
          >
          > previously just called by MM_swapImgResto re()
          >
          > Regards[/color]

          No changes are necessary to call function contained in an included
          javascript file.

          Your js file should not have the following:

          <script language="JavaS cript">
          <!--
          Javascript functions here
          //-->
          </script>


          Comment

          • Jamie

            #6
            Re: Include in many pages

            Thanks a million.

            All working now.

            :-)

            "McKirahan" <News@McKirahan .com> wrote in message
            news:b6ednWGXgZ CxAn_cRVn-vQ@comcast.com. ..[color=blue]
            > "Jamie" <jamieallison@h otmail.com> wrote in message
            > news:_1xEd.437$ Bb.406@newsfe5-win.ntli.net...[color=green]
            >> Just had a thought.
            >>
            >> My java code has 3 function which I call on the HTML page. Is there any
            >> particular way I have to call the function now it is included this way
            >> instead of the code directly there?
            >>
            >> Such as javascrips.ja/MM_swapImgResto re()
            >>
            >> previously just called by MM_swapImgResto re()
            >>
            >> Regards[/color]
            >
            > No changes are necessary to call function contained in an included
            > javascript file.
            >
            > Your js file should not have the following:
            >
            > <script language="JavaS cript">
            > <!--
            > Javascript functions here
            > //-->
            > </script>
            >
            >[/color]


            Comment

            • Grant Wagner

              #7
              Re: Include in many pages

              "McKirahan" <News@McKirahan .com> wrote in message
              news:b6ednWGXgZ CxAn_cRVn-vQ@comcast.com. ..[color=blue]
              > "Jamie" <jamieallison@h otmail.com> wrote in message
              > news:_1xEd.437$ Bb.406@newsfe5-win.ntli.net...[color=green]
              > > Just had a thought.
              > >
              > > My java code has 3 function which I call on the HTML page. Is there[/color][/color]
              any[color=blue][color=green]
              > > particular way I have to call the function now it is included this[/color][/color]
              way[color=blue][color=green]
              > > instead of the code directly there?
              > >
              > > Such as javascrips.ja/MM_swapImgResto re()
              > >
              > > previously just called by MM_swapImgResto re()
              > >
              > > Regards[/color]
              >
              > No changes are necessary to call function contained in an included
              > javascript file.
              >
              > Your js file should not have the following:
              >
              > <script language="JavaS cript">[/color]

              <script type="text/javascript">

              The language attribute has been deprecated.
              [color=blue]
              > <!--[/color]

              Not required.
              [color=blue]
              > Javascript functions here
              > //-->[/color]

              Not required.
              [color=blue]
              > </script>[/color]

              --
              Grant Wagner <gwagner@agrico reunited.com>
              comp.lang.javas cript FAQ - http://jibbering.com/faq


              Comment

              Working...