• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Query on window and document object  RSS feed

 
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • 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?
 
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It did work with both.
 
Bear Bibeault
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java Opera
  • 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
Sheriff
Posts: 67260
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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?

 
Whatever you say buddy! And I believe this tiny ad too:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!