Reputation: 173
I need to show the selected text into popup window, okay, I created the popup window and added event handler, for example.
$("body").on("click", function(){
var selectedText = window.getSelection().toString() ;
myPopupWindow.show(selectedText) ;
})
And then I show the text into the popup window, but when I select a text into the popup window it appears again, but I don't want to appear it again when popup is showing.
Upvotes: 0
Views: 77
Reputation: 5201
add an if
statement to check the visibility of your popup:
$("body").on("click", function() {
if ($("#popup").css("display") == "none") {
var selectedText = window.getSelection().toString() ;
myPopupWindow.show(selectedText);
}
})
Upvotes: 1
Reputation: 56
change your $("body") to something more specific like a container div of just the web content, so text selection in the popup doesn't trigger the same action.
Upvotes: 0