Hi all, I want to focus on a special textbox when page is loaded. I do this with js function focus() and it works fine. But when I open the page in a new tab in firefox, it doesn't focus on the textbox. any idea?
Firefox open in new tab opens in a background tab. If the page itself doesn't have focus, then it can't pass its focus to any element within the page.
In order to acheive the desired effect, you will need to set the focus on the control when the document first gains focus.
I agree with Mr.Paul. Here is the simple example
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="javascript">
<!--
function SetFocus()
{
document.getElementById('t1').focus();
}
//-->
</script>
</HEAD>
<BODY onLoad="SetFocus()">
<input type="text" id="t1">
<input type="text" id="t2">
</BODY>
</HTML>
Setting the focus on the first textbox.Whenever the new tab opens, set the proper url and the first textbox will gain the focus.
Moreover, when the new tab is clicked, the url is not set to the actual url of the file. After setting the url you will definitely find the textbox1 is having the focus.
yep. It doesn't work in firefox. i dunno why. But it works, if we do the following in firefox. go to Tools --> Options click on Tabs. Check the option "When i open a link in a new tab, switch to it immediately".
This will take you to the opened tab directly and onfocus works. This is not the solution. This will work only on your firefox ofcourse. can't guarantee users have that option checked. :(