Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Query on window and document object

 
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a query regarding window and document objects based on modal window.
Below is my code

My question is regarding this block
Should this not be 'document.onclick' instead of 'window.onclick'?

Below are definitions :
The window object represents the browser window.
The document object represents the HTML document loaded in that window.

Even though replacing window with document works, I want to know what is right here.
Is it right to click anywhere on browser to close modal?
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did work with both.
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what does that tell you?

Here's an instructive exercise: put a click handler on both. What happens? What does the result mean?
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

There's absolutely no difference if I replace window with document and vice versa.
In both cases, when I click on either x or the gray screen, the modal window is closed.
What would be the difference between browser window and html document loaded in the window?
modal.png
[Thumbnail for modal.png]
Modal screen
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Here's an instructive exercise: put a click handler on both. What happens? What does the result mean?

 
    Bookmark Topic Watch Topic
  • New Topic