On Jun 8, 3:35 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On Jun 8, 7:30 am, Amir Michail <amich...@gmail.comwrote:
I still don't understand the mechanism for copying the selection to
a RichTextArea widget in a gwt app via a bookmarklet.
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<bcontent</b<icontent</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?
Clicking on a bookmarklet normally redirects to an app url along with
some additional parameters added.
So maybe I need to get the selection as html first and add that html
to the
end of the url? Or is there some other way?
what is the URL ?
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.hr ef;s=(document.getSelection)?
document.getSelection():document.selection.createR ange().text;location.href='http://
studystickies.com#?cmd=add_resource&title=' + encodeURIComponent(t)
+'&url='+encodeURIComponent(u)+'&selection='+encod eURIComponent(s);
Add Sticky
==========
javascript
:t=document.title;u=document.location.hr ef;s=(document.getSelection)?
document.getSelection():document.selection.createR ange().text;location.href='http://
studystickies.com#?cmd=add_sticky&title=' + encodeURIComponent(t)
+'&url='+encodeURIComponent(u)+'&selection='+encod eURIComponent(s);
Amir