Loading ...
Sorry, an error occurred while loading the content.

RE: [NH] JavaScript Boilerplate ... with passed parameters

Expand Messages
  • Jeff Burrows
    Don - great stuff. I am glad to see more people discovering the joys of javascript! On suggestion: In your external file, have the function return a text
    Message 1 of 9 , Jun 7, 2002
    • 0 Attachment
      Don - great stuff. I am glad to see more people discovering the
      joys of javascript!

      On suggestion: In your external file, have the function return
      a text string rather than performing the document.write. This gives
      you more flexibility to reuse the function in the future.

      function printMessage(email, name) {
      var output;
      output = "Hey this footer will appear. If this page needs revision ";
      output += "write to: <a href='mailto:" + email + ">" + name + "</a>");
      return output;
      }

      then, in your document, just do:

      document.write(printMessage("passenger@...","Don Passenger"));

      This may seem picky, but it pays off in the long run.


      -----Original Message-----
      From: Don Passenger [mailto:dpasseng@...]
      Sent: Thursday, June 06, 2002 6:15 PM
      To: ntb-html@yahoogroups.com
      Subject: [NH] JavaScript Boilerplate ... with passed parameters


      Hey Christine, today instead of doing yoga (which looks like it hurts to me
      ..), I redid the javascript boilerplate from yesterday to make it even more
      useful by passing parameters. The possibilities are endless ...

      Here is the same example with parameters being passed. Say for example we
      had a site and wanted the same footer on every page, but wanted you to be
      able to write the particular person responsible for each page. We can use
      one footer .js external file, but by passing the name and email address, we
      can customize the footer on every page. Then if we need to update the
      footer, we only have one file to modify. This seems useful to me.

      Here are the revised files.

      The external JavaScript file named temp.js:
      //***
      function printMessage(email, name) {
      document.write ("Hey this footer will appear. If this page needs revision
      write to: <a href='mailto:" + email + ">" + name + "</a>");
      }
      //***

      The XHTML file:
      <!-- start -->
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>*** External JavaScript Boilerplate ***</title>
      </head>
      <body>

      <h3>How to Get a Boiler Plate Footer</h3>

      <p>First: you need a page.</p>

      <p>Second: you need a javascript file.</p>


      <p align="center">
      <script language="JavaScript">
      document.write('<script language="JavaScript" src="temp.js"><\/SCRIPT>');
      </script>
      <script language="JavaScript">
      printMessage("passenger@...","Don Passenger");
      </script>
      </p>
      </body>
      </html>
      <!-- stop -->





      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Don Passenger
      nope great improvement ... as with all things javascript I was working off of something I found along the way ... -- Don Passenger mailto:dpasseng@iserv.net
      Message 2 of 9 , Jun 7, 2002
      • 0 Attachment
        nope great improvement ...
        as with all things javascript I was working off of something I found along
        the way ...

        --
        Don Passenger
        mailto:dpasseng@...
        home: http://www.iserv.net/~dpasseng
        work: http://www.grcourt.org
        ----- Original Message -----
        From: "Jeff Burrows" <jeffb2nd@...>
        To: <ntb-html@yahoogroups.com>
        Sent: Friday, June 07, 2002 9:31 AM
        Subject: RE: [NH] JavaScript Boilerplate ... with passed parameters


        > Don - great stuff. I am glad to see more people discovering the
        > joys of javascript!
        >
        > On suggestion: In your external file, have the function return
        > a text string rather than performing the document.write. This gives
        > you more flexibility to reuse the function in the future.
        >
        > function printMessage(email, name) {
        > var output;
        > output = "Hey this footer will appear. If this page needs revision ";
        > output += "write to: <a href='mailto:" + email + ">" + name + "</a>");
        > return output;
        > }
        >
        > then, in your document, just do:
        >
        > document.write(printMessage("passenger@...","Don Passenger"));
        >
        > This may seem picky, but it pays off in the long run.
      • Krister Ekstrom
        Hi Jeff, On Fri, 7 Jun 2002, at 09:31:13 [GMT -0400] (which was 15:31 in my corner of the world) ,you typed: JB I am glad to see more people discovering the
        Message 3 of 9 , Jun 7, 2002
        • 0 Attachment
          Hi Jeff,

          On Fri, 7 Jun 2002, at 09:31:13 [GMT -0400] (which was 15:31 in my
          corner of the world) ,you typed:


          JB> I am glad to see more people discovering the
          JB> joys of javascript!

          I'm a newbie to all this, that is i've put up a website in the passt
          using, (dare i say it) Ms Frontpage. I've tried several html editors
          in the passt and decided to try taking the plunge and write a page or
          two with Notetab. I also want to discover the joys of Javascript and i
          wonder if there are clips out there or a very simple tutorial that can
          help a novise into the world of Javascript.


          --
          /Krister mailto:krister@...
        • Ian Rastall
          ... This looks like a good site: http://www.pageresource.com/jscript/index.html The guy who does the site, John Pollock, wrote a good book, which I own, called
          Message 4 of 9 , Jun 8, 2002
          • 0 Attachment
            On Fri, 7 Jun 2002 19:36:32 +0200, you wrote:

            >I also want to discover the joys of Javascript and i
            >wonder if there are clips out there or a very simple tutorial that can
            >help a novise into the world of Javascript.

            This looks like a good site:

            http://www.pageresource.com/jscript/index.html

            The guy who does the site, John Pollock, wrote a good book, which I
            own, called JavaScript: A Beginner's Guide. It's very good at giving
            you all the basics.

            Now that I'm a little more advanced, I'm reading a book published by
            O'Reilly, called JavaScript: The Definitive Guide, written by David
            Flanagan (Fourth Edition). That's the book you really need, but it's
            pretty hardcore stuff. Pollock's book is great for starting out, and I
            imagine his website is much the same.

            Ian
            --
            That's just my Buzzian theory. (Buzz Ruppelt)

            http://www.aspipes.org/
          • Jeff Burrows
            There is a really nice tutorial at: http://www.cfgatlin.com/javascript/index.html and also http://www.xs4all.nl/~ppk/js/ If you learned everything at these two
            Message 5 of 9 , Jun 8, 2002
            • 0 Attachment
              There is a really nice tutorial at:

              http://www.cfgatlin.com/javascript/index.html

              and also

              http://www.xs4all.nl/~ppk/js/

              If you learned everything at these two sites, you
              would become a JavaScript Jedi!


              -----Original Message-----
              From: Krister Ekstrom [mailto:krister@...]
              Sent: Friday, June 07, 2002 1:37 PM
              To: Jeff Burrows
              Subject: Newbie javascript question was Re: [NH] JavaScript Boilerplate
              ... with passed parameters


              Hi Jeff,

              On Fri, 7 Jun 2002, at 09:31:13 [GMT -0400] (which was 15:31 in my
              corner of the world) ,you typed:


              JB> I am glad to see more people discovering the
              JB> joys of javascript!

              I'm a newbie to all this, that is i've put up a website in the passt
              using, (dare i say it) Ms Frontpage. I've tried several html editors
              in the passt and decided to try taking the plunge and write a page or
              two with Notetab. I also want to discover the joys of Javascript and i
              wonder if there are clips out there or a very simple tutorial that can
              help a novise into the world of Javascript.


              --
              /Krister mailto:krister@...





              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
            • Adam Weston
              Krister: Before getting into javascript, I recommend getting pretty familiar with HTML and CSS. CSS is not a big deal to learn, and its a vital complement to
              Message 6 of 9 , Jun 8, 2002
              • 0 Attachment
                Krister:

                Before getting into javascript, I recommend getting pretty familiar with
                HTML and CSS. CSS is not a big deal to learn, and its a vital complement to
                HTML. Javascript will make more sense when you already know HTML/CSS. This
                is all just my humble opinion...

                To answer your question, A great place to learn HTML, CSS, and Javascript
                (and lots of other things) is:

                http://www.w3schools.com

                Have fun!


                -Adam


                ====== Original Message ======
                I'm a newbie to all this, that is i've put up a website in the passt
                using, (dare i say it) Ms Frontpage. I've tried several html editors
                in the passt and decided to try taking the plunge and write a page or
                two with Notetab. I also want to discover the joys of Javascript and i
                wonder if there are clips out there or a very simple tutorial that can
                help a novise into the world of Javascript.


                --
                /Krister mailto:krister@...



                _________________________________________________________________
                MSN Photos is the easiest way to share and print your photos:
                http://photos.msn.com/support/worldwide.aspx
              • stephen riddle
                Hi Krister Welcome to the hair pulling world of JavaScript! Visit the NoteTab site for some clipLibraries concerning javaScript. I first learned JavaScript
                Message 7 of 9 , Jun 8, 2002
                • 0 Attachment
                  Hi Krister
                  Welcome to the hair pulling world of JavaScript!
                  Visit the NoteTab site for some clipLibraries concerning javaScript.
                  I first learned JavaScript from a web site, but you'd better do a google
                  search (google.com) because it's been long enough it may not be there any
                  more.
                  G.luck
                  Stephen
                  > I'm a newbie to all this, that is i've put up a website in the passt
                  > using, (dare i say it) Ms Frontpage. I've tried several html editors
                  > in the passt and decided to try taking the plunge and write a page or
                  > two with Notetab. I also want to discover the joys of Javascript and i
                  > wonder if there are clips out there or a very simple tutorial that can
                  > help a novise into the world of Javascript.
                • Krister Ekstrom
                  Hi Jeff, Thanks a lot. Are there notetab specific tuts as well or better still, clips that taught me as i go? (Maybe that isn t possible) Anyways, i ll check
                  Message 8 of 9 , Jun 9, 2002
                  • 0 Attachment
                    Hi Jeff,

                    Thanks a lot. Are there notetab specific tuts as well or better still,
                    clips that taught me as i go? (Maybe that isn't possible)
                    Anyways, i'll check into both the tuts you gave me the address to and
                    the ones that someone else posted here.
                    Thanks so much, everyone!




                    --
                    /Krister mailto:krister@...
                  Your message has been successfully submitted and would be delivered to recipients shortly.