0

I wanted to display a 'simpler' text to help supplement kids reading exercise. As an example - as an example the text may read :

Johnny went to school and he surreptitiously ate his lunch early. I wanted to on-click" the word surreptitiously and display a simpler word, e.g. sneakily or something more understandable to a younger age student.

Ive used the following method to capture the clicked text, ( similar to examples sourced from this web site )

<!DOCTYPE html>

<head>
    <Title> Selected Text </Title>
</head>

<Body>
    <p>
      Johnny went to school and he surreptitiously ate his lunch early. I wanted to on-click" the                                         word surreptitiously and display a simpler word, e.g. sneakily or something more understandable to a younger age student.`
    </p>

    Selection:
    <br> 

    <textarea id="sel" rows="3" cols="50">
    </textarea>

    <p>Please select some text.</p>

</Body>

<script>
    function getSelectionText() {
        var text = "";

        if (window.getSelection) {
            text = window.getSelection().toString();
        }
        console.log(text);
        return text;
    }
    document.onmouseup = document.onkeyup = document.onselectionchange = function () {
        document.getElementById("sel").value = getSelectionText();
    };

</script>
</html>

This is a simplified version but places the text into a a text area but I was thinking of pop or similar

I read that as a security risk but was not clear on Vs Vs video. The similar word does not need to be as video simply a simple kit may be a simple html window display the 'sneakily' word so it becomes more understandable.

Although Ive worked as a coder ( when I was young LOL ) so appreciate suggestions of the best way to approach and any examples greatly appreciated.

Bryan

1
  • you could wrap the word you want to explain in a <span title="Sneaky"> surreptitiously</span>, you could use an onclick handler to display a custom tooltip. not sure why you suggest video? Commented Jul 11 at 12:04

0

Browse other questions tagged or ask your own question.