simple question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • timothy ma and constance lee

    simple question

    i am new to web page and start to write a simple homepage using pure html
    and javascript because it is a static page
    however, i want to ask that when i click link, can i pass the parameter to
    another page, by using javascript?


  • mike

    #2
    Re: simple question

    Yes
    "timothy ma and constance lee" <timcons1@shaw. ca> wrote in message
    news:cbBSc.8093 3$J06.865@pd7tw 2no...[color=blue]
    > i am new to web page and start to write a simple homepage using pure html
    > and javascript because it is a static page
    > however, i want to ask that when i click link, can i pass the parameter to
    > another page, by using javascript?
    >
    >[/color]


    Comment

    • Grant Wagner

      #3
      Re: simple question

      timothy ma and constance lee wrote:
      [color=blue]
      > i am new to web page and start to write a simple homepage using pure html
      > and javascript because it is a static page
      > however, i want to ask that when i click link, can i pass the parameter to
      > another page, by using javascript?[/color]

      <a href="yourpage. html?a=b">Next page</a>

      -- yourpage.html:

      <head>
      <title>Page 2</title>
      <script type="text/javascript">
      var searchString = window.location .search.substri ng(1);
      var Parameters = {};
      var nameValuePairs = searchString.sp lit(/&/);
      var nameValuePair;
      for (var i = 0; i < nameValuePairs. length; i++) {
      nameValuePair = nameValuePairs[i].split(/=/);
      Parameters[nameValuePair[0]] = nameValuePair[1];
      }

      // now you can access the value of a with
      // Parameters['a']
      </script>
      </head>
      <body>
      <script type="text/javascript">
      document.write(
      'The value of "a" was: ' +
      Parameters['a'] + '.'
      );
      </script>
      </body>

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

      Comment

      • timothy ma and constance lee

        #4
        Re: simple question

        thank

        But I tried it and it prompt me a lot of js error like
        var nameValuePairs = searchString.sp lit(/&/);


        "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
        news:411B83E3.4 22E85AE@agricor eunited.com...[color=blue]
        > timothy ma and constance lee wrote:
        >[color=green]
        > > i am new to web page and start to write a simple homepage using pure[/color][/color]
        html[color=blue][color=green]
        > > and javascript because it is a static page
        > > however, i want to ask that when i click link, can i pass the parameter[/color][/color]
        to[color=blue][color=green]
        > > another page, by using javascript?[/color]
        >
        > <a href="yourpage. html?a=b">Next page</a>
        >
        > -- yourpage.html:
        >
        > <head>
        > <title>Page 2</title>
        > <script type="text/javascript">
        > var searchString = window.location .search.substri ng(1);
        > var Parameters = {};
        > var nameValuePairs = searchString.sp lit(/&/);
        > var nameValuePair;
        > for (var i = 0; i < nameValuePairs. length; i++) {
        > nameValuePair = nameValuePairs[i].split(/=/);
        > Parameters[nameValuePair[0]] = nameValuePair[1];
        > }
        >
        > // now you can access the value of a with
        > // Parameters['a']
        > </script>
        > </head>
        > <body>
        > <script type="text/javascript">
        > document.write(
        > 'The value of "a" was: ' +
        > Parameters['a'] + '.'
        > );
        > </script>
        > </body>
        >
        > --
        > Grant Wagner <gwagner@agrico reunited.com>
        > comp.lang.javas cript FAQ - http://jibbering.com/faq
        >[/color]


        Comment

        • Grant Wagner

          #5
          Re: simple question

          I suppose it's possible the example I provided wrapped, or you made a mistake
          copying/pasting it into your own page. Perhaps you could provide a complete
          copy/paste of the problem code, or a page where the example does not work, and
          I will take a look.

          timothy ma and constance lee wrote:
          [color=blue]
          > thank
          >
          > But I tried it and it prompt me a lot of js error like
          > var nameValuePairs = searchString.sp lit(/&/);
          >
          > "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
          > news:411B83E3.4 22E85AE@agricor eunited.com...[color=green]
          > > timothy ma and constance lee wrote:
          > >[color=darkred]
          > > > i am new to web page and start to write a simple homepage using pure[/color][/color]
          > html[color=green][color=darkred]
          > > > and javascript because it is a static page
          > > > however, i want to ask that when i click link, can i pass the parameter[/color][/color]
          > to[color=green][color=darkred]
          > > > another page, by using javascript?[/color]
          > >
          > > <a href="yourpage. html?a=b">Next page</a>
          > >
          > > -- yourpage.html:
          > >
          > > <head>
          > > <title>Page 2</title>
          > > <script type="text/javascript">
          > > var searchString = window.location .search.substri ng(1);
          > > var Parameters = {};
          > > var nameValuePairs = searchString.sp lit(/&/);
          > > var nameValuePair;
          > > for (var i = 0; i < nameValuePairs. length; i++) {
          > > nameValuePair = nameValuePairs[i].split(/=/);
          > > Parameters[nameValuePair[0]] = nameValuePair[1];
          > > }
          > >
          > > // now you can access the value of a with
          > > // Parameters['a']
          > > </script>
          > > </head>
          > > <body>
          > > <script type="text/javascript">
          > > document.write(
          > > 'The value of "a" was: ' +
          > > Parameters['a'] + '.'
          > > );
          > > </script>
          > > </body>[/color][/color]

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

          Comment

          Working...