HighDots Forums  

Re: onload

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: onload in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Random
 
Posts: n/a

Default Re: onload - 06-01-2005 , 02:43 AM






ganeshnarayan wrote:
Quote:
Hi, i have a form with name "abc". in that i have 4 textboxes(inputbox)
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

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



Reply With Quote
  #2  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: onload - 06-06-2005 , 03:55 PM






Random wrote:

Quote:
(
document.getElementById ?
document.getElementById( 'qqq' )
: document.all[ 'qqq' ]
).focus();
This fails e.g. if a) document.getElementById 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.getElementById) == 'function'
Quote:
| (t == 'object' && document.getElementById)))
? document.getElementById('qqq')
: (document.all && document.all['qqq'])))
Quote:
| {focus: function(){}}
).focus();

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


PointedEars


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.