This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Murach's Java Programming and have Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Query on window and document object  RSS feed

 
pramod talekar
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66041
140
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
Author and ninkuma
Marshal
Posts: 66041
140
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
Author and ninkuma
Marshal
Posts: 66041
140
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!