A pop-up message will appear when the text is highlighted.

I am trying to find a way to show a pop-up message when a user tries to select and copy text from a paragraph. I searched the net for possible solutions, but could not find anything that would trigger a pop-up message when selecting text or a random part of a paragraph.

I looked at that . But it seems like it is using a div block, not a popup.

Can you help?

It seems that @Nishit Maheta's answer solved my problem. Soon I am updating the message with my decision.

Thank you all

+4
source share
3 answers

Try the following:

tinyMCE.init({
    mode: "exact",
    elements: "test",
    skin: "o2k7",
    skin_variant: "red",

    setup: function (ed) {
        ed.onMouseUp.add(function (ed, e) {
            var x = tinyMCE.activeEditor.selection.getContent();
            if(x)
              alert(x);
        });
    }
});

JSFIDDLE DEMO

0
source

Bootstrap Popover. ,

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h3>Popover Example</h3>
  <p  data-toggle="popover" title="Popover Header" data-content="Some content inside the popover">Toggle popover</p>
</div>

<script>
$(document).ready(function(){
    $('[data-toggle="popover"]').popover();   
});
</script>

</body>
</html>
0

This works well for me, hope it solves your problem.

 $("#myDiv").mousedown(function(){
    
              $("#myDiv").mouseup(function(){
    
                         $("#myPopUp").show();
              });
    });
#myPopUp
{
    display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="myDiv">
    hello please select the text and see
</div>
<div id="myPopUp">
    popover message
</div>
Run codeHide result
0
source

Source: https://habr.com/ru/post/1611253/


All Articles