+++ /dev/null
-function getSelectionHtml() {
- 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;
-}
-
-function stylizeHighlightedString(col)
-{
- var range = window.getSelection().getRangeAt(0);
- console.log(range)
- var selectionContents = range.extractContents();
- var span = document.createElement("span");
- span.appendChild(selectionContents);
- span.setAttribute("class","uiWebviewHighlight");
- span.style.backgroundColor = col;
- span.style.color = "white";
- range.insertNode(span);
-}
-
-function f_wanneer() {
- stylizeHighlightedString("red")
-}
-
-function f_wat() {
- stylizeHighlightedString("green")
-}
-
-function f_waar() {
- stylizeHighlightedString("blue")
-}
-
-
-window.onload = function() {
- var box = document.getElementById('htab');
- box.addEventListener('contextmenu', function(e) {
- console.log(getSelectionHtml());
- });
-}
-
-