On Jun 5, 11:14 pm, bhomass <bhom...@gmail.com> wrote:
> I looked up some cross browser code. but I am getting different
> results
>
> if (document.getSelection) {
> var range = document.getSelection().createRange();;
> } else if (document.selection && document.selection.createRange) {
> var range = document.selection.createRange();
> } else {
> var str = "Sorry, this is not possible with your browser.";
> }
>
> I use the range to get the parent Element, range.parentElement();
>
> originally (using $doc), I get back a div, now I am getting back the
> BODY element.
> document.selection does not seem to be equivalent to $doc.selection,
> even though it removes the browser incompatibility.
>
> any ideas?
Use script like this one:
public static native String getSelection() /*-{
var txt = '';
if ($wnd.getSelection) {
txt = $wnd.getSelection();
} else if ($wnd.document.getSelection) {
txt = $wnd.document.getSelection();
} else if ($wnd.document.selection) {
txt = $wnd.document.selection.createRange().text;
}
return txt;
}-*/;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---