/    Sign up×
Community /Pin to ProfileBookmark

Cannot move focus to div

I have a simple app that loads a div with a relatively large text file via a standard Ajax call. Once the div has been loaded, I want to move the focus to it, but my call to focus() doesn’t do the job. I thought maybe this was a timing issue, so I tried delaying things a little (then a lot) with a call to setTimeout(), but that didn’t help.

You can see the app in question at:

[url]www.wiseware.com/test[/url]

Thanks

JAS

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@toicontienNov 03.2008 — DIV tags cannot receive focus. You'll need some sort of tag that can receive focus, like an <a> tag.
Copy linkTweet thisAlerts:
@MrNobodyNov 03.2008 — As mentioned, these are the tags which can receive focus (see "applies to" list):

http://msdn.microsoft.com/en-us/library/ms536425(VS.85).aspx
Copy linkTweet thisAlerts:
@garybarnesMay 27.2009 — I found that if the DIV (or SPAN) has a width or height style attribute it will receive focus, e.g. add style="min-height:100px" to your DIV and it can be selected. Can't find a fix for images though, it's driving me mad!
×

Success!

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