views:

345

answers:

2

Ext.getBody().focus() does not appear to be working correctly in IE6. When a user navigates to a new ExtJS tab, I need to ensure he can no longer type into a CKEditor instance (hidden after navigating to a new tab) in which he might have been typing. The following code works in FF, but not IE6.

for( var instanceName in CKEDITOR.instances ) {
    CKEDITOR.instances[instanceName].focusManager.forceBlur();  // also 
                                                                // not working 
                                                                // in IE6
}
Ext.getBody().focus();

Any suggestions?

A: 

I believe all major browsers including IE 6 support the document.activeElement property. If I understand correctly, you need to remove focus from the active form element when the user clicks a tab? Assuming you have access to some sort of event when the tab is clicked, try this:

if(document.activeElement) {
    //Call blur() to remove focus from the active (focused) element
    document.activeElement.blur(); 
}

If you want to disable all input to that field you would want to also give it the "disabled" property.

Matt Baker
Thanks for the reply. This doesn't work either - perhaps because the "current" focus is located in an iFrame.
Upper Stage
I believe it would still work, if it's in an iframe you just need to get at *it's* document object:`window.frames['your_frame'].document.activeElement`
Matt Baker
+1  A: 

I used this workaround; I created an input field with zero height and zero width and move the focus to this field to blur a CKEditor field/instance.

Upper Stage