How to make a button loose focus when page is loaded
When my JSP page gets loaded, the button (actually an image button with
onfocus property) gets focused. So, on pressing enter it gets clicked. It
is a small, part of a bigger problem. How can I make the button lose focus
when page is loaded?
<html>
<head>
</head>
<body>
<div onkeypress =handleEnter()>
name <input type="text" src='Create.gif' >
</br>
<input type="image" src='Create.gif' onclick="alert('not done')">
<input type="image" src='Create.gif' onclick="alert('done')">
</div>
</body>
<script>
function handleEnter()
{
if(window.event.keyCode==13)
{
alert('nothing');
event.cancelBubble=true;
}
}
</script>
</html>
both the alert box for nothing and not done has been show
No comments:
Post a Comment