On 5 juin, 22:14, bhomass <[email protected]> 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?
http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideJavaScriptNativeInterface
"When accessing the browser's window and document objects from JSNI,
you must reference them as $wnd and $doc, respectively. Your compiled
script runs in a nested frame, and $wnd and $doc are automatically
initialized to correctly refer to the host page's window and
document."
'document' above references the iframe's document where your code runs
(i.e. the *.cache.html).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---