Saturday, January 28, 2012

blure() and assign() Method in JavaScript

blure() Method in JavaScript
 
The blur() method is used to remove focus from an element.
 
JavaScript Code:
 
<script language="JavaScript">
 
function removeFocus(){
   document.getElementById("removeButton").blur();
   document.getElementById("removeButton").innerText = "Its focus!";
   alert("Its focus!"); 
} 
</script>
 
HTML Code:
 
<input id="removeButton" 
       type="button" 
       onclick="removeFocus();" 
       value="Input Focus!" 
       onFocus="this.innerText='In focus. Click me to lose focus'" />
 
 
assign() Method in JavaScript
 
The assign() method loads a new document.
 
JavaScript Code:
 
<script language="JavaScript">
    function newdoc()
    {
        location.assign("http://anildroisys.blogspot.com/");
    }
</script>
 
HTML Code:
<input type="button" value="Load new page" onclick="this.newdoc();" />

No comments: