Exforsys.com
 
Home Tutorials JavaScript
 

JavaScript DOM Window Object

 

JavaScript Window Object Self Property

Page 3 of 3


JavaScript Window Object Self Property:

The self property of the Window object refers to the current window and returns a reference to the current window.


General syntax of self property of Window Object:




window.self



An example to understand this concept:



 <html>
  <head>
    <script type="text/javascript">
     function checkwindow()
   
 {
      if (
window.top!=window.self)
     
{
       
 document.write("The window is not current
         window!!!!!
")
     
}
     else
    
{
       
document.write("The window is current window!!!!!")
    
}
    }

  
</script>
 </head>
 <
body>
    <input
type="button" onclick="checkwindow()"
   
value="Check the Window by clicking Here">
 </body>
</html>



In the above example a button is displayed with message



Check the Window by clicking Here



When this button is clicked, the function checkwindow() is called and the Current Window status is checked. If the Window top is equal to window.self (which has the reference to the current window) then else statement gets fired and the message:



The window is current window!!!!!



is displayed.



If the Window top is not equal to window.self (which has the reference to the current window) then if statement gets fired and the message:



The window is not current window!!!!!



is displayed.




First Page: JavaScript DOM Window Object


Read Next: JavaScript Windows Object Properties Part I



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape