Wysiwyg jquery focus

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Mini
Forum Newbie
Posts: 23
Joined: Mon Dec 04, 2006 4:39 am
Location: Netherlands

Wysiwyg jquery focus

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Wysiwyg jquery focus

Post by John Cartwright »

Take a look at http://simple.procoding.net/2008/03/21/ ... in-jquery/, and more specifically the user comments.
Post Reply