IE: JS error with myTextarea.focus() in image_assist_textarea.js
Eric Cosky - June 21, 2008 - 18:25
| Project: | FCKeditor - WYSIWYG HTML editor |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
When inserting an image with Drupal 6.2, Image Assist 6.x-1.x-dev, FCKEditor 2.6.1 and FCKeditor module 6.x-1.x-dev, the focus() call below (from image_assist_textarea.js) throws an ignorable exception when debugging is enabled in IE7.
function insertToEditor(content) {
// Insert the image
if (myDoc.selection) {
// IE
myTextarea.focus();The error it gives me is "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

#1
hmm have the same issue but with IE5 i was testing with. maybe then for all IE's
when i press the 'Split Summary at cursor' button on first screen for new upload. and also then it errors but goes to 2nd screen. and errors when press insert... still inserts. and i think goes back to a blank page which says 'Start Over' which seems wrong... (no 'Image submitted Successfully' screen?)
i was testing with latest beta1 release
#2
i duplicated this issue again today...
i goto create content and start a new Page type.
then type usual title/file info and get to Body tag. I start typing there and hit the 'Split Summary at Cursor' button and get an error
on the focus() line in teaser.js here:
function split_teaser() {
body[0].focus();//here
The error in IE5 is "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."
I hit Save and next screen actually i hit Insert and all was good today. Not sure how i got the same error as above user but yesterday it was a one-two punch, somewhere on last screen i got the same error with myTextarea.focus(); also. Thought it was related.
ill try to dig up more if people more knowledgable with this mod dont see this thread
#3
I guess that means you have to disable your Wysiwyg editor first, in front of clicking the "Split summary at cursor" button. That's at least, what the error message tells you exactly: "Can't move focus to the control because it is invisible, ..." - and with an enabled Wysiwyg editor (FCKeditor, TinyMCE, etc), the original textarea is indeed hidden (invisible).
#4
yeh its weird though. I dont exclude any pages from having FCK on them... So FCK should show up on all textareas... On the main content-type create/edit page (like node/add/story or node/12/edit), FCK loads, replacing the normal textarea, and showing 'Show summary in full view' instead of 'Split Summary at Cursor' which is expected. I can hit 'Switch to Plain Text editor' and 'Split summary at cursor' button now is there and works (which is expected).
But in the Image Assist popup, it does not have the same behavior. so pretend from that node edit page, i click on Image Assist helper button, which goes to the Image Assist Popup (img_assist/load/fckeditor?textarea=body)... I would expect FCK to show up there for its Body field (aka same workflow as node edit form), but I see a regular textarea with the 'Split summary at cursor' which i wouldnt expect (i expect to be greeted with a FCKeditor textarea and 'Show summary in full view', and changes to Split button when I change to the plain text editor (which wont happen since Switch is part of FCK, which doesnt show up)...
anyway, i was thinking... well having 'Split summary' button is normal being coupled with no FCK editor, just dont know why its not showing up, and i can research that later as i might have disabled FCK to that path in my settings... so i click on the Split button expecting it to work, and i get that error in IE/FF. I think its more of a bug with FCK or Image Assist.
sidenote: i do think Fck is possibly trying to take control of that Body field, as the textarea's size seems to dynamically change when loading webpage /is smaller than usual, but it can't, so Image Assist might mess up cause of this.
i research more into it later. i dont see anything crazy in the html, same id for teaser/body fields. not sure why FCK cant hook into edit-body and make it work correctly
EDIT: temp solution for now, FCK settings -> Visibility, set to exclude on drupal path: img_assist/upload
i think FCK should be able to be enabled and still work in Image Assist with summary buttons, just like the node-edit pages, but for some reason isnt
#5
Given these facts, moving over to FCKeditor project.
#6
Hmm I didn't inspect this issue deeply, I think we have at least two separate issues here... anyway anyone interested in better compatibility between FCKeditor and Image Assist (6.x-1.x) is encouraged to download the latest dev release of FCKeditor module that should be available today (16.IX.2008) after 1 PM or in the worst scenario tomorrow.
Make sure that you move the new img_assist_fckeditor.js into modules/img_assist folder and refresh your browser's cache (remember that to use FCKeditor and Image Assist, img_assist_fckeditor.js must be moved from the fckeditor folder into img_assist). Main changes: Image Assist should appear as a button in the FCKeditor toolbar, resizing image assist using mouse should now work as expected.
#7
cool, thanks for looking into and fixing it. what were the 2 separate issues that you mentioned?
#8
Well... just by taking a quick look I saw that in original post image_assist_textarea.js was mentioned, while img_assist_fckeditor.js should be used.
On the other side you mentioned some problems with teaser.js which could mean that this problem occured due to previous problems with handling teasers in the FCKeditor module.
As I said, I didn't try to reproduce this particular issue though, having a hope that the letest dev release solves all problems.
@armyofda12mnkeys: please confirm, do the latest dev release of FCKeditor module work fine for you with Image Assist 6.x-1.0-beta1?
Anyone else willing to the the latest dev release?
#9
hmmmmm not sure that solves all of it. new problem... In IE5, this line
addToolbarElement('ImageAssist', 'Basic', 0); in modules/fckeditor/plugins/imgassist/fckplugin.js gives a 'object expected' error when arriving to create node/edit node page. thought maybe cause i didnt see a Basic in fckeditor.config.js, but i commented that out and next line also errored.
The popup image page i think is fine now. defaults at split at cursor. i guess there are some settings to override and use the default teaser instead of FCK on image assist screen maybe.
i know IE6 is a bit old, but would be nice that it worked there. FF seems to be fine with that function.
btw i did use the newer image_assist_fckeditor.js file before and that file was same date/filesize, guess since i was using newer versions of fck anyway.
any ideas about the IE error, i googled a bit and i see that function usually is used with an objectconfig.addToolbarElement( maybe? or function params is expecting an object?
#10
Thanks for the info about the same size of img_assist_fckeditor.js. I forgot to commit the newer version which should now work fine when FCKeditor is used in a popup mode.
Toolbars "Basic" and "Default" are defined in modules/fckeditor/fckeditor/fckconfig.js.
I tried to reproduce this issue with IE5. I downloaded IE 5.5/SP2 but it works for me (not quite well as it works in IE6 or FF but it is functional). Anyway, I don't get the "object expected'" error. Did you remember to clear browser's cache?
It's possible that my version of IE 5.5 for XP is not exactly the same as yours (I downloaded it here: http://www.quirksmode.org/browsers/multipleie.html).
I'll appreciate your help on resolving this issue, you could try debugging addToolbarElement() function to see where exactly this problem occurs.
#11
i actually was trying to find where addToolbarElement() is defined so i can debug more.
did a quick search in fck/img_assist modules and didnt find (probably cause using Windows Search instead of awk/sed linux stuff hehe). which file is that in?
Sorry i updated my post, i was testing with IE6 (not IE5). i use MultipleIE sometimes but sometimes i think it messes up so i use virtual machine microsoft provides to test on IE6 at home which seems to be safest bet to test. i have regular IE6 at work.
Anyway i test with new module, see the new button in the toolbar, the popup though gives error when i click Split Summary (thought FCK would show up there but it didnt like before, anyway the split summary should just split Body field like normal but instead errors:)
// Split the teaser from the body.
function split_teaser() {
body[0].focus();//here
hmmm even FF2 got an error there, although those NS errors i think with other webapps ive done, disapear and might not be a problem in FF, maybe ill restart and retest:
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://drupaltest1/misc/drupal.js?9 :: anonymous :: line 234" data: no]
http://drupaltest1/misc/drupal.js?9
Line 234
i see some TinyMCE/Image_assist peeps have had this problem before maybe related, dont know what the fix is:
http://drupal.org/node/162383
http://drupal.org/node/208414#comment-786497
#12
Ok, I think I understand at least what's the second problem.
I have installed the latest Image Assist 6.x-1.x-dev (md5_file hash: 7a5d778a973954557c60d243e2c028a8, Last updated: September 13, 2008 - 00:10).
6.x-2.x seems to be unusable at this moment due to #308005: Theme registry needs template file in /includes.
When Image Assist is installed, it displays two icons one at the top and one at the bottom. I always used that one at the bottom, but you've probably clicked the one at the top.
Because textarea at the top is invisible until you click "Split summary at cursor" and apparently Image Assist icon at the top is assigned to that invisible textare, it throws an error. I have disabled FCKeditor and this problem still occurs, so looks like an Image Assist issue.
Now.. where does the addToolbarElement() error comes from...
- could you let me know your detailed configuration (FCKeditor module, Image Assist module)? {lease confirm that you're using either latest Image Assist 6.x-1.x-dev or 6.x-1.0-beta1.
- does it happen in Garland theme?
- could you attach a screencast how does it happen, or even better send me a PM with a link to a dev site and instructions to reproduce it? It will be much easier for me to reproduce this bug locally then.
#13
Hey,
I am using
Drupal 6.4
Image assist 6.x-1.0-beta1
FCKeditor 6.x-1.x-dev
[ and if useful, also use: Image 6.x-1.0-alpha3,
IMCE 6.x-1.1]
and a copy of Garland (i havent done anything to the theme to customize it so its just same Garland that comes default now).
ill try to get a working example up as soon as I can when come home from work or screencast.
btw where is addToolbarElement function defined? i wanted to add some alert messages to debug but i dont know where it is.
#14
This function is defined in fckeditor.config.js.
There is a chance that you're getting errors because when you upgraded you've decided to not overwrite this particular file, perhaps it may be a good idea to move this function into fckeditor.utils.js.