Sunday, January 12, 2014

Another example of "Global Variable" in JavaScript

File 1.js

var a=5; 
function mahi()

    alert(window.value);  //accessing global variable  
}


File 1.htm

<html>
<head>
<script type="text/javascript" src="1.js"></script>
</head>
<body>
<form>
    <input type="button" value="button" onclick="mahi()"/>
</form>
</body>
</html>

No comments:

Post a Comment