I have a following code which I tried to assign onfocus event to the element, so that whenever the element gets focused, call alert. 
However, alert only appears when the page loaded, and never after that. 

```
<html>
<head>
</head>
<body onload = "loadings();">
<div>   
    <form>  
        <input type="text" id="foo"/>
    </form>
</div>

<script type="text/javascript">
function loadings(){
    document.getElementById("foo").onfocus = alert("foo"); 
}
</script>
</body>
</html>

```

Please note that I can't do `<input type="text" id="foo" onfocus="alert('foo')"/>` for the thing I am trying to achieve.

Also this should work in Firefox, Chrome, IE, Safari.

Thanks in advance!