473,226 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Setting initial focus in html using Javascript - Pocket IE on Windows 2003 Pocket PC

This HTML has a bit of Javascript at the end that puts the initial
focus on the userID field. It works great on Windows2000 running IE6,
but the initial focus never goes to the userID field on Windows 2003
PocketPC (Windows Mobile) running Pocket IE.

<html><head><title>WMS - P280WF100 - Login</title><META
HTTP-EQUIV='expires' VALUE='0'>
</head>
<body>
<form name="frmLogon" action='p280wp100' method='get'>
<table>
<tr>
<td>User ID</td>
<td>
<input id='userID' name='userID'
type='text'
maxlength=10
size=10
</input></td>
</tr>
<tr>
<td>Password</td>
<td>
<input id='password' name='password'
type='password'
maxlength=10
size=10

</input></td>
</tr>

<tr>
<td colspan=2><center><input type='submit' accesskey='L'
value='Login'></center></input></td>
</tr>
</table>
</form>

<hr>
<script language=javascript>
function window.onload(){window.frmLogon.userID.focus();}
</script>
</body></html>
Jul 23 '05 #1
2 7478
dsnyder wrote:
This HTML has a bit of Javascript at the end that puts the initial
focus on the userID field. It works great on Windows2000 running IE6,
but the initial focus never goes to the userID field on Windows 2003
PocketPC (Windows Mobile) running Pocket IE.
I have only had one short opportunity to examine a Pocket IE but it was
rapidly obvious that it was not a cut down version of desktop IE (and
not surprisingly so, as desktop IE is enormous). It seems likely that
creating code to work on Pocket IE should be done following general
cross-browser coding principles, so avoiding IE-isms and avoiding any
reliance on the error correcting behaviour of desktop IE (best achieved
by validateing HTML source code).

<snip> <input id='userID' name='userID'
type='text'
maxlength=10
size=10
> </input></td>

^^^^^^^^
Input elements are empty, they do not have a closing tag.

<snip> ... <center><input type='submit' accesskey='L'
value='Login'></center></input> ...
The DOM created for scripting from HTML has a tree-like structure, and
formally valid HTML also has a tree-like structure (allowing an easy
translation from HTML into a DOM). But above you have and opening CENTER
tag, and opening INPUT tag, a closing CENTER tag and then a closing
INPUT tag. The closing INPUT tag is invalid anyway (as I mentioned
above) but what is the browsers supposed to make of this strange
overlapping of elements? Desktop IE error-corrects it (it has no choice
as this is the sort of nonsense HTML that Microsoft Word outputs as a
matter of course), but I am told that 50% of desktop IE's code is
error-correcting and then will just not fit into Pocket IE.

<snip> <script language=javascript>
Valid HTML 4 requires that script elements have a type attribute,
rendering the language attribute redundant.

<script type="text/javascript">
function window.onload(){window.frmLogon.userID.focus();}

<snip>

ECMA 262 (3rd edition) specifies a function declaration as having an
identifier as a function name, not a property accessor. This is another
IE-ism, and maybe Pocket IE does not understand it. Cross-browser code
would assign a function expression to the - window.onload - property.

Accessing named forms as properties of the global (window) object is not
cross-browser either. Accessing forms as named members of the -
document.forms - collection is the most widely (seemingly universally)
supported mechanism available on HTML browsers.

window.onload = function(){
document.forms['frmLogon'].elements['userID'].focus();
};

Richard.
Jul 23 '05 #2

Richard:

Thanks for the info. I found this bit of code on this web site:
http://www.htmlhelp.com/faq/html/all.html

<script type='text/javascript'><!--
document.frmLogon.userID.focus();
//--></script>

This seems to work in both of my environments and is closer to your
example than my original code. I'll try your example and see how it
goes.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
1
by: Blake Versiga | last post by:
How do i set the focus on a Textbox upon initial display of the page?
1
by: Brian Henry | last post by:
I remember this from before but cant remember how to do it, its been over a year since i have... how do you set the initial focus to a text box on page load? isn't it a java script you have to do?...
4
by: Gawel | last post by:
Hajo, from time to time I need to run "aspnet_regiis.exe -i" because javascript does not work. It is strange because it happens about twice per month. I have no idea what is going on. thanks...
1
by: Mitch W | last post by:
I have an application that I have developed on Windows XP that references the Microsoft CDO for Windows 2000 and attempts to send a message using: CDO.Message cdoMsg = new CDO.Message(); It...
1
by: Steve2007 | last post by:
Hi I have the following form in my html page: <form name="mapserv" method=GET action=""> <input type="hidden" name="timeFiltering"> <input type="hidden" name="filteringType"> <input...
6
by: roop1 | last post by:
Hello gits, I found this snippet that you offered to another person and I was wondering if it wouldn't work for me as well: <script type="text/javascript"> function...
1
by: rameshch45 | last post by:
How to set the initial focus on the cursor in my form's first field? I dont want to use javascript for that as I have many forms - is there any attribute to set?
2
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... ...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.