I am developing a java application using SWT. It has a browser embeded in it.I have to add copy,selectall,find functions to this app.I have used this script to implement copy function
final String SCRIPT01 = "var html = \"\";"+
"if (typeof window.getSelection != \"undefined\") {"+
"var sel = window.getSelection();"+
"if (sel.rangeCount) {"+
"var container = document.createElement(\"div\");"+
"for (var i = 0, len = sel.rangeCount; i < len; ++i) {"+
"container.appendChild(sel.getRangeAt(i).cloneContents());"+
"}"+
"html = container.innerHTML;"+
"}"+
"} else if (typeof document.selection != \"undefined\") {"+
"if (document.selection.type == \"Text\") {"+
"html = document.selection.createRange().htmlText;"+
"}" +
"}" +
"return html";
I actually found this code on SO and i have no idea what this is.But it worked for me.Can anyone tell what script it is.I thought it was javascript but i think im wrong and any links to tutorials of this script will be very useful.I want to learn this script and see if i can use it to implement "select all" and "find" functions.