<html>
<head>
<script type="text/javascript">
var pub ="全局变量";
function sayHello(){
alert(pub);
}
</script>
</head>
<body onload="sayHello()">
</body>
</html>
<html>
<head>
<script type="text/javascript">
function sayHello(){
var p ="局部变量";
alert(p);
}
</script>
</head>
<body onload="sayHello()">
</body>
</html>