Page 1 of 1

Wysiwyg jquery focus

Posted: Thu Feb 26, 2009 11:28 am
by Mini
well I'm making a wysiwyg with jquery and for some reason I can't set the focus to the iframe.

Here's some of the code:

Code: Select all

 
$( $(self.iframe).document() ).find('body').selectRange(0,0);
 
$.fn.selectRange = function(start, end) {   
        var element = $(this).get(0);
        if (element.createTextRange) {
            var range = element.createTextRange();
            range.collapse(true);
            range.moveEnd('character',   end);
            range.moveStart('character', start);
            range.select();
        }
        else if (element.setSelectionRange) {
            element.focus().setSelectionRange(start, end);
        }
        return $(this);
    }
 
That method will work for textareas and inputs but not for an iframe.

Does any1 know a solution or anything?

Thanks

Re: Wysiwyg jquery focus

Posted: Thu Feb 26, 2009 11:32 am
by John Cartwright
Take a look at http://simple.procoding.net/2008/03/21/ ... in-jquery/, and more specifically the user comments.