কিভাবে copy, paste এবং cut behavior detect করা যায়?



কিভাবে copy, paste এবং cut behavior detect করা যায়? 


 
 
অনেক সময় application এর মধ্যে copy, paste এবং cut behavior detect করার প্রয়োজন হয়। যদিও এর জন্য অনেক সুন্দর সুন্দর tools রয়েছে যার মাধ্যমে effeciently client side এ অনেক behavior detect করা সম্ভব।
নিচে এ সম্পর্কত একটি ছোট program দেয়া হল :



copy, pest এবং cut behavior detect করার জন্য অনুরূপ(corresponding) event গুলিকে bind করতে হবে :
$("#textA").bind('copy', function() {
$('span').text('copy behaviour detected!')
});
$("#textA").bind('paste', function() {
$('span').text('paste behaviour detected!')
});
$("#textA").bind('cut', function() {
$('span').text('cut behaviour detected!')
});

আপনি যদি jQuery 1.4x use করে থাকেন তবে এটি নিচের মত multiple events declaration suppolrt করবে :
$("#textA").bind({
copy : function(){
$('span').text('copy behaviour detected!');
},
paste : function(){
$('span').text('paste behaviour detected!');
},
cut : function(){
$('span').text('cut behaviour detected!');
}
});

Try it yourself :

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>

<style type="text/css">
span{
color:blue;
}
</style>

</head>
<body>
<h1>jQuery copy, paste and cut example</h1>
<form action="#">
<label>TextBox : </label>
<input id="textA" type="text" size="50"
value="Copy, paste or cut message here" />
</form>

<span></span>

<script type="text/javascript">

$(document).ready(function() {

$("#textA").bind({
copy : function(){
$('span').text('copy behaviour detected!');
},
paste : function(){
$('span').text('paste behaviour detected!');
},
cut : function(){
$('span').text('cut behaviour detected!');
}
});

});
</script>
</body>
</html>

Demo :


 

Comments

Popular posts from this blog

HSC all text book Download | এইচএসসি সব পাঠ্য বই ডাউনলোড

একাদশ দ্বাদশ শ্রেণীর বই সমূহ ডাউনলোড – HSC Books Download pdf

আপনি 2022 সালে এই বক্স অফিস হিটগুলির কয়টি দেখেছেন?