Javascript DOM onfocusin Event via HTML Tag onfocusin function

Introduction

onfocusin Event via HTML Tag onfocusin function may not work as expected in Chrome, Safari and Opera 15+.

object.onfocusin = function(){
       myScript};

This example uses the HTML DOM to assign an "onfocusin" event to an input element.

View in separate window

<!DOCTYPE html>
<html>
<body>
Enter your name: <input type="text" id="fname">
<script>
document.getElementById("fname").onfocusin = function() {myFunction()};

function myFunction() {/*  w  ww  . j a  v  a 2 s  .c om*/
  document.getElementById("fname").style.backgroundColor = "red";
}
</script>

</body>
</html>
Bubbles:
Cancelable:
Event type:
Supported HTML tags:











Yes
No
FocusEvent
ALL HTML elements, EXCEPT:
<base>,
<bdo>,
<br>,
<head>,
<html>,
<iframe>,
<meta>,
<param>,
<script>,
<style>, and
<title>



PreviousNext

Related