কিভাবে 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 :
লেখকঃ ঢাকা প্রকৌশল ও প্রযুক্তি বিশ্ববিদ্যায়ের(DUET) কম্পিউটার সায়েন্স এ্যান্ড ইঞ্জিনিয়ারিং(CSE) বিভাগের ৪র্থ বর্ষের এক জন ছাত্র। তিনি ওয়েব ডিজাইন, ওয়েব ডেভলপমেন্ট এর বিভিন্ন বিষয় যেমন : এইচটিএমএল, সিএসএস, জাভাস্ক্রিপ্ট, জে কোয়েরি, পিএইচপি, .Net ইত্যাদি বিষয়ের উপর অভিজ্ঞ। তিনি ACM ICPC সহ বিভিন্ন আন্তর্জাতিক প্রোগ্রামিং প্রতিযোগীতায় অংশগ্রহন করেছেন। তাকে ফেসবুকে অনুসরন করতে এখানে ক্লিক করুন।