/    Sign up×
Community /Pin to ProfileBookmark

Set focus for table

// Javascript code for onFocus event
// FIREFOX Event
if (document.addEventListener) {
window.onload = function (evt) {
//Set the focus to table in firefox
document.getElementById(‘table_id’).focus();
}

}
else {

/* for IE 6 and IE 7 */
window.onload = function (evt) {

//Evaluates an expression after a specified number of milliseconds has elapsed.
setTimeout(fieldFocus , 100 );
}
/* TODO : Still to check in all other browsers */

}

//function for field focus
function fieldFocus() {
document.getElementById(‘table_id’).focus();
}

I written abouve to code to set focus to table it is working for IE not for FIREFOX

Pls give me ideas

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@mrhooNov 08.2007 — 
  • 1. use document.getElementById('table_id').scrollIntoView(true)

  • 2. focus on an element contained by the table that can receive focus

  • 3. reload the page with the table id set as a hash-

    location.href=location.pathname+'#table_id'
  • Copy linkTweet thisAlerts:
    @toicontienNov 08.2007 — The TABLE element cannot receive focus in most browsers. Only the following elements may receive focus:

    A

    BUTTON

    IFRAME

    INPUT

    LABEL

    SELECT

    TEXTAREA

    You'll need to create an <a> tag near the TABLE, give it an Id, then set focus to the <a> tag. You can create an empty <a> tag so it doesn't have any text visible.
    Copy linkTweet thisAlerts:
    @KarniRevuriauthorNov 10.2007 — Actually , have done it with location.href=location.pathname+'#table_id'

    But as per rerequirement we dont want to see the '#table_id' in URL

    any ideas?
    Copy linkTweet thisAlerts:
    @toicontienNov 12.2007 — Create an <a> tag near the table and set focus to it.
    Copy linkTweet thisAlerts:
    @roma1123Mar 24.2011 — Actually we can do something to make a table focusable.

    See this post for details:

    http://extremedev.blogspot.com/2011/03/make-html-elements-like-div-span-table.html
    ×

    Success!

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