/    Sign up×
Community /Pin to ProfileBookmark

top-left control

Hi,

I am a JavaScript newbie (have long experience in C/C++).
I have to set focus on top-left input controll on my page. I have no idea how to do that. The page is *.aspx and code-behind is C#.
I think that it would be easiest in JavaScript.

Please help.

Thank you.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMar 28.2005 — Try

<script type="text/javascript">
<!--
onload = function () {document.forms[0].elements[0].focus()}
// -->
</script>
Copy linkTweet thisAlerts:
@iljeauthorMar 28.2005 — Is element[0] always a top-left one?

what about bottom-left?
Copy linkTweet thisAlerts:
@CharlesMar 28.2005 — Is element[0] always a top-left one?

what about bottom-left?[/QUOTE]
They are numbered sequentially starting from 0. That's why I suggested that you give it a try.

Another option is to give your element a name and use something like:

<script type="text/javascript">
<!--
onload = function () {document.forms[0]['bottom-left'].focus()}
// -->
</script>
×

Success!

Help @ilje 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.7,
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,
)...