onfocusin ইভেন্ট
পরিভাষা ও ব্যবহার
onfocusin ইভেন্ট এলিমেন্টটি ফোকাস করা যাচ্ছে তখন ঘটে
টীকা:onfocusin ইভেন্ট এর অনুরূপ onfocus ইভেন্ট。
টীকা:যদিও ফায়ারফক্স onfocusin ইভেন্ট সমর্থিত না, আপনি onfocus ইভেন্টের ক্যাপচার লিস্টিনার (addEventListener() পদ্ধতির useCapture পারামিটার) ব্যবহার করে সাব-ইলেকট্রনটি ফোকাস করা হয়েছে কিনা না তা নির্ধারণ করতে পারেন。
টীকা:onfocusin ইভেন্ট এর সঙ্গে onfocusout ইভেন্টবিপরীত
ইনস্ট্যান্স
উদাহরণ 1
যখন ইনপুট ফিল্ড ফোকাস করা যাচ্ছে তখন জাভাস্ক্রিপ্ট চালু করুন:
<input type="text" onfocusin="myFunction()">
পাতার নিচে আরও TIY ইনস্ট্যান্স আছে。
ব্যবহারিক বিবরণ
HTML তে:
<element onfocusin="myScript">
জাভাস্ক্রিপ্টে (চ্রোম, সাফারি এবং ওপেরা 15+ তে সঠিকভাবে কাজ করতে পারে না):
object.onfocusin = function(){myScript};
জাভাস্ক্রিপ্টে, addEventListener() পদ্ধতি ব্যবহার করে:
object.addEventListener("focusin", myScript);
Note:ইন্টারনেট এক্সপ্লোরার 8 বা আরও পুরানো সংস্করণগুলি এটা সমর্থিত না addEventListener() পদ্ধতি。
কার্যকরি বিবরণ
বারবার প্রক্রিয়াকরণ: | Supported |
---|---|
বারবার প্রক্রিয়াকরণ: | বাতিল করা যেতে পারে: |
অনসমর্থিত | FocusEvent |
সমর্থিত HTML ট্যাগ: | সমস্ত HTML ইলেকট্রন, বর্তমানে: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> এবং <title> |
DOM version: | Level 2 Events |
Browser support
The numbers in the table indicate the first browser version that fully supports the event.
event | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
onfocusin | Supported | Supported | 52.0 | Supported | Supported |
Note:The onfocusin event may not work as expected in Chrome, Safari, and Opera 15+ using JavaScript HTML DOM syntax. However, it should be used as an HTML attribute and with the addEventListener() method (see the syntax examples below).
more examples
example 2
use "onfocusin" and "onfocusout" events together:
<input type="text" onfocusin="focusFunction()" onfocusout="blurFunction()">
example 3
event delegation: set the useCapture parameter of addEventListener() to true (for focus and blur):
<form id="myForm"> <input type="text" id="myInput"> </form> <script> var x = document.getElementById("myForm"); x.addEventListener("focus", myFocusFunction, true); x.addEventListener("blur", myBlurFunction, true); function myFocusFunction() { document.getElementById("myInput").style.backgroundColor = "yellow"; } function myBlurFunction() { document.getElementById("myInput").style.backgroundColor = ""; } </script>
example 4
event delegation: using focusin event:
<form id="myForm"> <input type="text" id="myInput"> </form> <script> var x = document.getElementById("myForm"); x.addEventListener("focusin", myFocusFunction); x.addEventListener("focusout", myBlurFunction); function myFocusFunction() { document.getElementById("myInput").style.backgroundColor = "yellow"; } function myBlurFunction() { document.getElementById("myInput").style.backgroundColor = ""; } </script>