<html>
<head></head>
<body>
<input type="text" id="mytext" />
<span id="myspan"></span>
<script type="text/javascript">
var mytext=document.getElementById('mytext');
var myspan=document.getElementById('myspan');
mytext.onfocus = function(){
myspan.innerHTML = '得到焦点';
}
mytext.onblur = function(){
myspan.innerHTML = '失去焦点';
}
window.onbeforeunload=function(){
var v = mytext.value;
alert(v);
if(v){
return '444';
}
}
</script>
</body>
</html>