Wysiwyg jquery focus
Posted: Thu Feb 26, 2009 11:28 am
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:
That method will work for textareas and inputs but not for an iframe.
Does any1 know a solution or anything?
Thanks
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);
}
Does any1 know a solution or anything?
Thanks