Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textrange focus problem

Status
Not open for further replies.

5ilver5aracen

Programmer
Oct 24, 2004
32
GB
Hi, I am using a div to edit some text. The div is set to contentEditable=true. The problem I have is that when the user clicks on a button/image/link that is outside the div the cursor disappears from the div. So if that button needs to apply some formatting to the textrange in the div it fails because the textrange loses focus. I've tried setting the buttons to onfocus=blur() but that doesnt seem to work. Does anyone know how to keep the focus on the textrange?
Many thanks in advance.
 
Do you need to know specifically what text is being edited within the div?
Do you have more than one div that will be editable?

If only one div editable then you know programmatically where to be applying whatever it is the button will do.
If more than one will be editable then use an event that sets a variable to the name of the div when that div gets focus then you will always know which one is selected.

Focus HAS to change in order for your button to execute, the trick is just knowing where to apply the actions of that button. You can then set focus back to your div when the button is done executing.
document.myform.myfield.focus();

Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top