Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting focus on div
Message
De
09/12/2014 09:51:15
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Getting focus on div
Divers
Thread ID:
01612058
Message ID:
01612058
Vues:
55
I have adjusted my code to have a better handling on setting focus on a div. I thought I would share this approach in case someone would need it.

Once my div is created, I insert the middle section of code to have a universal approach which will add support for all browsers to receive the focus on the div:
cScript = cScript + "window.parent.oDiv=window.parent.document.createElement(""div"")" + oApp.cCR

' Use to have a universal way to add support for set focus on the div
' This is cross browser
' This allows to press Esc immediately
' This avoids the Enter key, when the div is active, on Firefox, to bring the user to the home page
' This avoids the div to bounces the Html content to the right if the browser is not wide enough
cScript = cScript + "window.parent.oDiv.tabIndex=-1" + oApp.cCR

cScript = cScript + "window.parent.document.body.appendChild(window.parent.oDiv)" + oApp.cCR
Then, in pretty much the same section, down below, when I have finished aligning my div, I have this to set the focus:
cScript = cScript + "window.parent.oDiv.focus()" + oApp.cCR
Internet Explorer does not require the middle section to work. However, having it there will make it ok with Firefox, Google Chrome and Safari.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Répondre
Fil
Voir

Click here to load this message in the networking platform