/    Sign up×
Community /Pin to ProfileBookmark

control.focus() does not work with Nestcape 7.1 and Mozilla 1.4

Hello,

I am making a page with ASP .NET, and I want to focus on one textbox control on every load of the page. My code works fine on IE, but when it comes to Netscape 7.1 and Mozilla 4.1 it doesn’t. Here is my page HTML:

<%@ Page Language=”vb” AutoEventWireup=”false” Codebehind=”SMD mounting.aspx.vb” Inherits=”paperless_SMD.smd_mounting” codePage=”1252″ clientTarget=”uplevel”%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<title>SMD Mounting</title>
<META http-equiv=”Content-Type” content=”text/html; charset=Windows-1252″>
<meta content=”Microsoft Visual Studio .NET 7.1″ name=”GENERATOR”>
<meta content=”Visual Basic .NET 7.1″ name=”CODE_LANGUAGE”>
<meta content=”JavaScript” name=”vs_defaultClientScript”>
<meta content=”http://schemas.microsoft.com/intellisense/ie5” name=”vs_targetSchema”>
[COLOR=DarkRed]<SCRIPT language=”JavaScript”>
<!–

function focus_control ()
{

var control = document.getElementById(‘TB_PCB’);

if( control != null )
{
control.focus()
}

}
//–>>;
</SCRIPT>
</HEAD>
<body bgColor=”#74cca7″ MS_POSITIONING=”GridLayout” onload=”focus_control()”>[/COLOR] <form id=”Form1″ method=”post” runat=”server”>
<asp:label id=”Label1″ style=”Z-INDEX: 101; LEFT: 232px; POSITION: absolute; TOP: 16px” runat=”server”
Font-Size=”Large” ForeColor=”Olive” Width=”176px”> SMD mounting</asp:label><asp:button id=”bn_save_data” style=”Z-INDEX: 102; LEFT: 152px; POSITION: absolute; TOP: 408px; Design_Time_Lock: True”
tabIndex=”6″ runat=”server” Width=”96px” Enabled=”False” Text=”Save data” Font-Size=”Small” Design_Time_Lock=”True”></asp:button><asp:button id=”bn_start_nl” style=”Z-INDEX: 103; LEFT: 432px; POSITION: absolute; TOP: 240px”
tabIndex=”8″ runat=”server” Width=”112px” Text=”Start new lot” Font-Size=”Small” Visible=”False”></asp:button><asp:textbox id=”tb_product” style=”Z-INDEX: 104; LEFT: 152px; POSITION: absolute; TOP: 184px”
tabIndex=”1″ runat=”server” Width=”89px”></asp:textbox><asp:textbox id=”tb_pcb” style=”Z-INDEX: 105; LEFT: 152px; POSITION: absolute; TOP: 360px” tabIndex=”5″
runat=”server” Width=”144px” Font-Size=”Small”></asp:textbox><asp:label id=”err_label” style=”Z-INDEX: 106; LEFT: 16px; POSITION: absolute; TOP: 64px” runat=”server”
ForeColor=”Red” Width=”760px” Height=”48px” Font-Size=”Small”></asp:label><asp:label id=”Label2″ style=”Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 184px” runat=”server”
Width=”64px” Font-Size=”Small”>Product</asp:label><asp:label id=”Label3″ style=”Z-INDEX: 108; LEFT: 16px; POSITION: absolute; TOP: 360px” runat=”server”
Width=”88px” Font-Size=”Small”>PCB number</asp:label><asp:label id=”Label4″ style=”Z-INDEX: 109; LEFT: 16px; POSITION: absolute; TOP: 248px” runat=”server”
Width=”104px” Font-Size=”Small”>Lot number</asp:label><asp:label id=”ln” style=”Z-INDEX: 110; LEFT: 152px; POSITION: absolute; TOP: 248px” runat=”server”
Width=”258px”></asp:label><asp:label id=”Label5″ style=”Z-INDEX: 111; LEFT: 16px; POSITION: absolute; TOP: 120px” runat=”server”
Width=”64px” Font-Size=”Small”>Lot size</asp:label><asp:label id=”lot_size” style=”Z-INDEX: 112; LEFT: 96px; POSITION: absolute; TOP: 120px” runat=”server”
Width=”80px” Font-Size=”Small”></asp:label><asp:label id=”Label6″ style=”Z-INDEX: 113; LEFT: 312px; POSITION: absolute; TOP: 120px” runat=”server”
Width=”104px” Font-Size=”Small”>Current lot size:</asp:label><asp:label id=”current_lot_size” style=”Z-INDEX: 114; LEFT: 432px; POSITION: absolute; TOP: 120px”
runat=”server” Width=”64px” Font-Size=”Small”></asp:label><asp:label id=”Label7″ style=”Z-INDEX: 115; LEFT: 16px; POSITION: absolute; TOP: 280px” runat=”server”
Width=”48px” Height=”11px” Font-Size=”Small”>Line:</asp:label><asp:dropdownlist id=”ddl_line” style=”Z-INDEX: 116; LEFT: 152px; POSITION: absolute; TOP: 280px”
tabIndex=”3″ runat=”server” Width=”144px” Font-Size=”Small”>
<asp:ListItem Value=”Line 1″ Selected=”True”>Line 1</asp:ListItem>
<asp:ListItem Value=”Line 2″>Line 2</asp:ListItem>
</asp:dropdownlist><asp:textbox id=”tb_pcb_ssln” style=”Z-INDEX: 117; LEFT: 152px; POSITION: absolute; TOP: 320px”
tabIndex=”4″ runat=”server” Width=”144px” Enabled=”False” Font-Size=”Small”></asp:textbox><asp:label id=”Label8″ style=”Z-INDEX: 118; LEFT: 16px; POSITION: absolute; TOP: 320px” runat=”server”
Width=”120px” Font-Size=”Small”>PCB Syscoset LN</asp:label><asp:button id=”btn_print” style=”Z-INDEX: 119; LEFT: 432px; POSITION: absolute; TOP: 280px”
tabIndex=”9″ runat=”server” Width=”113px” Text=”Print lot data” Font-Size=”Small” Visible=”False”></asp:button><asp:button id=”Button2″ style=”Z-INDEX: 120; LEFT: 272px; POSITION: absolute; TOP: 184px” tabIndex=”2″
runat=”server” Width=”112px” Text=”Select product” Font-Size=”Small”></asp:button><asp:button id=”btn_reset_form” style=”Z-INDEX: 121; LEFT: 432px; POSITION: absolute; TOP: 184px”
tabIndex=”7″ runat=”server” Width=”112px” Text=”Reset form” Font-Size=”Small”></asp:button>
<asp:CheckBox id=”ChkBox” style=”Z-INDEX: 122; LEFT: 152px; POSITION: absolute; TOP: 152px” runat=”server”
Width=”208px” Text=”Discard PCB axial lot number” Enabled=”False” Checked=”True” Font-Size=”Small”></asp:CheckBox>
<asp:Label id=”Label9″ style=”Z-INDEX: 123; LEFT: 432px; POSITION: absolute; TOP: 152px” runat=”server”
Width=”152px” Height=”24px” Font-Size=”Small”>PCB labels length:</asp:Label>
<asp?ropDownList id=”DDL_serials_length” style=”Z-INDEX: 124; LEFT: 608px; POSITION: absolute; TOP: 152px”
runat=”server” Width=”54px” Font-Size=”Small”>
<asp:ListItem Value=”3″>3</asp:ListItem>
<asp:ListItem Value=”4″>4</asp:ListItem>
<asp:ListItem Value=”5″>5</asp:ListItem>
<asp:ListItem Value=”6″ Selected=”True”>6</asp:ListItem>
<asp:ListItem Value=”7″>7</asp:ListItem>
<asp:ListItem Value=”8″>8</asp:ListItem>
<asp:ListItem Value=”9″>9</asp:ListItem>
<asp:ListItem Value=”10″>10</asp:ListItem>
<asp:ListItem Value=”11″>11</asp:ListItem>
</asp?ropDownList>
<asp:Label id=”Label_s2″ style=”Z-INDEX: 125; LEFT: 152px; POSITION: absolute; TOP: 216px”
runat=”server” Width=”128px” ForeColor=”Yellow”></asp:Label></form>
</body>
</HTML>

What might be the cause for this problem?

Thanks,
Aleksander

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieJun 25.2005 — Haven't bothered looking through yours but this does worl in Fx:

&lt;INPUT type="text" id="asdf"&gt;
&lt;SCRIPT type="text/javascript"&gt;
&lt;!--
(function(){var a=document.getElementById("asdf");if(a)a.focus();})();
//--&gt;
&lt;/SCRIPT&gt;


You should do it immediately after the input rather than onload otherwise it may be some time before your images load and it actually takes focus.
×

Success!

Help @Alex_bd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...