NS does not accept linkname.click

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

    #1

    NS does not accept linkname.click

    <a id="hiddenLink1 " name="hiddenLin k1" href="page1.htm "
    target="someTar get1" >1 </a>
    <a id="hiddenLink2 " name="hiddenLin k2" href="page2.htm "
    target="someTar get1" >2 </a>


    <A href="javascrip t:donothing();"
    onClick="hidden Link1.click();s etTimeout('hidd enLink2.click() ',2000);">open
    two</A>

    works in Opera and IE, but not in NS. In NS, it has no action at all.

    I tried document.links['hiddenLink1'].click(); IE gave me error, object
    document.link.h iddenLink1 can not be empty.



  • Randy Webb

    #2
    Re: NS does not accept linkname.click

    nntp wrote:
    [color=blue]
    > <a id="hiddenLink1 " name="hiddenLin k1" href="page1.htm "
    > target="someTar get1" >1 </a>
    > <a id="hiddenLink2 " name="hiddenLin k2" href="page2.htm "
    > target="someTar get1" >2 </a>
    >
    >
    > <A href="javascrip t:donothing();"
    > onClick="hidden Link1.click();s etTimeout('hidd enLink2.click() ',2000);">open
    > two</A>[/color]



    [color=blue]
    > works in Opera and IE, but not in NS. In NS, it has no action at all.[/color]

    Did you check the Javascript Console? Tools>Web Development>Jav ascript
    Console.

    Error: hiddenLink1 is not defined.




    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • Lee

      #3
      Re: NS does not accept linkname.click

      nntp said:[color=blue]
      >
      > <a id="hiddenLink1 " name="hiddenLin k1" href="page1.htm "
      > target="someTar get1" >1 </a>
      > <a id="hiddenLink2 " name="hiddenLin k2" href="page2.htm "
      > target="someTar get1" >2 </a>
      >
      >
      ><A href="javascrip t:donothing();"
      >onClick="hidde nLink1.click(); setTimeout('hid denLink2.click( )',2000);">open
      >two</A>
      >
      >works in Opera and IE, but not in NS. In NS, it has no action at all.[/color]

      It has an action, but you need to open the Javascript console to see it.
      It should display an error because there is no global variable named
      "hiddenLink 1". IE, and apparently Opera, allows you to get away with
      that, but it's poor practice. To get a reference to an element with a
      given id, use getElementById( ), as in:

      document.getEle mentById('hidde nLink1').click( );

      However, I don't think links have a "click()" method in Netscape.

      You also shouldn't use the javascript: pseudo-protocol like that.
      It may cause errors if Javascript is disabled.

      <html>
      <head>
      <script type="text/javascript">
      function openTwoWindows( url1,url2){
      window.open(url 1);
      setTimeout("win dow.open('"+url 2+"')",2000);
      }
      </script>
      </head>
      <body>
      <a href="errorPage .html"
      onclick="openTw oWindows('page1 .htm','page2.ht m');return false"[color=blue]
      >open two</a>[/color]
      </body>
      </html>

      Comment

      • nntp

        #4
        Re: NS does not accept linkname.click

        Do you know how I can do click in NS?

        Here is the one with getelementbyid

        <a id="hiddenLink1 " name="hiddenLin k1" href="http://www.google.com"
        target="someTar get1" >1 </a>
        <a id="hiddenLink2 " name="hiddenLin k2" href="http://www.yahoo.com"
        target="someTar get1" >2 </a>
        <SCRIPT language="JavaS cript">
        function donothing() {return ;}
        </SCRIPT>

        <A href="#" onClick="docume nt.getElementBy Id('hiddenLink1 ').click();
        setTimeout('doc ument.getElemen tById(\'hiddenL ink2\').click() ',2000);">open
        2</A>

        Works in IE and Opera. STILL not working in NS. I guess it is the click()
        not working in NS;

        I need to pass the REFERRER into it, so I really need click(). Frames are
        not an option.



        Comment

        • RobG

          #5
          Re: NS does not accept linkname.click

          nntp wrote:
          [color=blue]
          > <a id="hiddenLink1 " name="hiddenLin k1" href="page1.htm "
          > target="someTar get1" >1 </a>
          > <a id="hiddenLink2 " name="hiddenLin k2" href="page2.htm "
          > target="someTar get1" >2 </a>
          >
          >
          > <A href="javascrip t:donothing();"
          > onClick="hidden Link1.click();s etTimeout('hidd enLink2.click() ',2000);">open
          > two</A>
          >
          > works in Opera and IE, but not in NS. In NS, it has no action at all.
          >
          > I tried document.links['hiddenLink1'].click(); IE gave me error, object
          > document.link.h iddenLink1 can not be empty.
          >[/color]

          You don't need it to click the link. Try:

          <A href="#"
          onclick="
          location = document.getEle mentById('hidde nLink1');

          setTimeout('loc ation=document. getElementById( \'hiddenLink2\' )',2000)
          ;">open 1</A>

          Incidentally, the setTimeout will not work (I think)
          because you navigate to the first link, so the page is
          unloaded. You can't execute a script from a page that is
          no longer in the browser (gee, wouldn't that really screw
          with users's minds!! Isn't the unload function nasty
          enough?)

          Cheers, Rob

          Comment

          Working...