簡體   English   中英

突出顯示文本時彈出消息

[英]Pop up message to appear when text is highlighted

當用戶試圖突出顯示並復制段落中的文本時,我試圖找到一種顯示彈出消息的方法。 我在網上搜索可能的解決方案,但是當找到文本或段落的隨機部分時,我找不到任何會觸發彈出消息的消息。

我看過這個 但似乎它使用div塊而不是彈出。

似乎@Nishit Maheta的答案解決了我的問題。 不久我將用我的解決方案更新帖子。

嘗試這個:

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

試試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>

它對我很有用,希望它能解決你的問題。

  $("#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> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM