J
Jack Jones
<head>
<script>
function say(message) {
var text;
document.body.onclick = function () {alert(text);};
}
</script>
</head>
<body onload="say('test')">
This is a <i>test</i> document.
</body>
I was trying to write an example that would pring an alert box when the
page is displayed and then an alert box every time the document is
clicked, thus proving that var text is always in scope. But sadly
nothing happens instead.
<script>
function say(message) {
var text;
document.body.onclick = function () {alert(text);};
}
</script>
</head>
<body onload="say('test')">
This is a <i>test</i> document.
</body>
I was trying to write an example that would pring an alert box when the
page is displayed and then an alert box every time the document is
clicked, thus proving that var text is always in scope. But sadly
nothing happens instead.