Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

focus() in IE browser

Status
Not open for further replies.

anamika

Programmer
Oct 31, 2000
2
US
Hi,
I am having some problem with focus() method.The focus() method is suppose to set cursor at the beginning of the textbox if the focus() is set to textbox.But this code is doing good in NS browser but the same code in IE the cursor is going after 'a'(which is default value of textbox) in onClick event.The same code is working properly in onLoad() event even in IE.I don't undestand why it is problem with onClick evnt.I need immediate help in this.

Here is the code:
<html><head></head><body onLoad=&quot;setFocus()&quot;>

<form name=&quot;myForm&quot; method=&quot;POST&quot;>

<input type=&quot;text&quot; name=&quot;blabla&quot; size=20 value=&quot;a&quot;>
<input type=&quot;reset&quot; name=&quot;change&quot; onClick=&quot;setFocus()&quot;>
<script language=&quot;javascript&quot;>
function setFocus()
{
document.myForm.blabla.focus();
}
</script>
</form>
</body>
</html>
 
Hi anamika,

all you need to add the return false after calling the setFocus function.. here..

<input type=&quot;reset&quot; name=&quot;change&quot; onClick=&quot;setFocus(); return false;&quot;>

This should solve your problem.. =)

Chiu Chan
cchan@gefmus.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top