onload

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

    onload


    Hi, i have a form with name "abc". in that i have 4 textboxes(input box
    and one hyperlink(name/id ="qqq").

    On loading the page i need the focus to the hyperlink.

    How can i achieve this?

    Kindly help me..

    Thanx in adv.

    Ganes

    --
    ganeshnaraya
    -----------------------------------------------------------------------
    ganeshnarayan's Profile: http://www.highdots.com/forums/member.php?userid=10
    View this thread: http://www.highdots.com/forums/showthread.php?t=137124

  • Random

    #2
    Re: onload

    ganeshnarayan wrote:[color=blue]
    > Hi, i have a form with name "abc". in that i have 4 textboxes(input box)
    > and one hyperlink(name/id ="qqq").
    >
    > On loading the page i need the focus to the hyperlink.
    >
    > How can i achieve this?
    >
    > Kindly help me..
    >
    > Thanx in adv.
    >
    > Ganesh
    >
    >
    > --
    > ganeshnarayan[/color]


    Try getting a reference to the 'qqq' hyperlink and using its .focus()
    method:
    <body onLoad="
    (
    document.getEle mentById ?
    document.getEle mentById( 'qqq' )
    : document.all[ 'qqq' ]
    ).focus();
    ">

    Comment

    • RobG

      #3
      Re: onload

      ganeshnarayan wrote:[color=blue]
      > Hi, i have a form with name "abc". in that i have 4 textboxes(input box)
      > and one hyperlink(name/id ="qqq").
      >
      > On loading the page i need the focus to the hyperlink.
      >
      > How can i achieve this?[/color]

      <script type="text/javascript">

      function focusOnLink(x) {
      x = document.links[x] || document.all[x];
      if ( x && x.focus ) x.focus();
      }

      </script>

      <body onload="focusOn Link('qqq');">

      <a name="qqq" id="qqq" href="..." ... >...</a>


      --
      Rob

      Comment

      • ganeshnarayan

        #4
        Re: onload


        Hi,

        It was very helpful.

        Thanx Again to Both

        Ganes

        --
        ganeshnaraya
        -----------------------------------------------------------------------
        ganeshnarayan's Profile: http://www.highdots.com/forums/member.php?userid=10
        View this thread: http://www.highdots.com/forums/showthread.php?t=137124

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: onload

          Random wrote:
          [color=blue]
          > (
          > document.getEle mentById ?
          > document.getEle mentById( 'qqq' )
          > : document.all[ 'qqq' ]
          > ).focus();[/color]

          This fails e.g. if a) document.getEle mentById is for some reason a property,
          but not a method (function property), b) if there is no document.all or
          c) neither method returns an object that has the focus() method. Therefore
          (untested):

          var t;
          (
          document
          && (((t = typeof document.getEle mentById) == 'function'
          || (t == 'object' && document.getEle mentById)))
          ? document.getEle mentById('qqq')
          : (document.all && document.all['qqq'])))
          || {focus: function(){}}
          ).focus();

          I prefer using a wrapper method like dhtml.js:getEle m() and an
          `if' statement for this.


          PointedEars

          Comment

          Working...