JavaScript Saving highlighted text to a string save highlighted text pdf,save highlighted text from web page,

I'm making a web application that splits the screen into two windows, with one side a web based text editor and the other side just a normal window. I am trying to find a way to be able to have a user highlight some text on the browser side and then auto-save the highlighted text into a string where I would then be able to manipulate the string.

Does anybody have any ideas? Any help would be greatly appreciated.

Answer:1

        function getSelectionText() {
            var text = "";
            if (window.getSelection) {
                text = window.getSelection().toString();
            } else if (document.selection && document.selection.type != "Control") {
                text = document.selection.createRange().text;
            }
            return text;
        }
        $(document).ready(function (){
           $('div').mouseup(function (e){
               alert(getSelectionText())
           })
        });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
        Hello, this is a highlight text test
    </div>
Answer:2

Ok definitely not know what to do so I ask for help, I've looked everywhere and can not find solution. This is a long question involved the following files: sizeCalc.js, main.qml, MainForm.ui.qml, ...

Ok definitely not know what to do so I ask for help, I've looked everywhere and can not find solution. This is a long question involved the following files: sizeCalc.js, main.qml, MainForm.ui.qml, ...

I am new to AngularJS, so please be gentle. I want to retrieve data from my backend using the $resource property of AngularJS, however it seems that the property is getting loaded before the actual ...

I am new to AngularJS, so please be gentle. I want to retrieve data from my backend using the $resource property of AngularJS, however it seems that the property is getting loaded before the actual ...

  1. angularjs $resource resolve promise

Im trying to post data back to a webmethod located in Default.aspx jquery code: data = "{'saveData':'testtestest'}" $.ajax({ type: "POST", contentType: "application/json; ...

Im trying to post data back to a webmethod located in Default.aspx jquery code: data = "{'saveData':'testtestest'}" $.ajax({ type: "POST", contentType: "application/json; ...

  1. ajax call always goes to error
  2. ajax call always
  3. ajax call always returns error
  4. ajax call always returns success
  5. ajax call always fails
  6. ajax call always error
  7. ajax call always function
  8. ajax request always error
  9. ajax request always
  10. ajax request always pending
  11. ajax request always fails
  12. jquery ajax call always returns error
  13. jquery ajax call always
  14. jquery ajax call always goes to error

to draw a rectangle in google map, I need to know northwest and southeast points to construct a LatLngbounds first. In my situation, I want to draw a rectangle with specific northwest point and a ...

to draw a rectangle in google map, I need to know northwest and southeast points to construct a LatLngbounds first. In my situation, I want to draw a rectangle with specific northwest point and a ...

  1. draw rectangle google maps
  2. draw rectangle google earth