Skip to content Skip to sidebar Skip to footer

Changes To Selection And Range Functionality In Ie8

I'm having to debug a WYSIWYG javascript based HTML editor that is failing in IE8. It's only designed for use in IE so that should simplify the solution. Here's the existing code t

Solution 1:

Ok, the answer was pretty simple! It must be a change in the way IE8 keeps the focus on the iframe, by adding foo.focus(); to the code below, everything works as expected. Hope this helps someone, but it probably won't if their code was written properly in the first place :)

function isAllowed() {
    var sel;
    var obj;

        foo.focus();
        sel = foo.document.selection;

        if (sel.type != "Control")
        {
            var rng = sel.createRange();
            obj = rng.parentElement();
        } else {
            obj = sel.createRange()(0);
        }

        if (obj.isContentEditable) {
            foo.focus();
            returntrue;
        } else {
            returnfalse;
        }
}

Solution 2:

Have you considered using a debugger or putting alerts into the javscript so you can figure out what is happening. Figure out which element is being returned and maybe you will find your problem. It's possible it returning some parent element instead of the iframe (I'm just guessing here). Also, I am not sure why it would run if they have only clicked in the area though. Maybe I misunderstanding something.

Post a Comment for "Changes To Selection And Range Functionality In Ie8"