try this :
<script>
function copyCont(){
var ifr=document.getElementById("s");
ifr.contentDocument.body.appendChild(getSelection().getRangeAt(0).cloneContents())
}
</script>
<iframe id="s" onload="this.contentDocument.designMode='on';"></
iframe>
<div>content<b> content</b> <i> content</i></div>
<button onclick="copyCont()">Copy contents of selection in IFRAME</
button>
The gwt app may not be open when the user clicks on the bookmarklet.
Moreover, if the bookmarklet opens it and tries to access the rich
text editor therein, won't that be a security violation?
This is for my Study Stickies gwt app:
http://studystickies.com
Currently, the bookmarklets look like this (but they do not preserve
formatting in selections):
Add Resource
============
javascript:t=document.title;u=document.location.href;s=(document.getSelection)?
document.getSelection():document.selection.createRange().text;location.href='http://
studystickies.com#?cmd=add_resource&title=' + encodeURIComponent(t)
+'&url='+encodeURIComponent(u)+'&selection='+encodeURIComponent(s);
Add Sticky
==========
javascript:t=document.title;u=document.location.href;s=(document.getSelection)?
document.getSelection():document.selection.createRange().text;location.href='http://
studystickies.com#?cmd=add_sticky&title=' + encodeURIComponent(t)
+'&url='+encodeURIComponent(u)+'&selection='+encodeURIComponent(s);
Amir