By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

detect mouse click event

P: n/a
Hi,
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

thanks

Jul 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.
<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #2

P: n/a
Thanks.
I can't access the body from my page as it is in a master page (i'm
doing asp.net). However I have a javascript function bodyLoad() which
is called at body load and in which I can do stuff. How can I assigne
the onclick event in this function ?
Evertjan. wrote:
wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #3

P: n/a
wrote on 07 jul 2006 in comp.lang.javascript:
Evertjan. wrote:
>wrote on 07 jul 2006 in comp.lang.javascript:
When I click on a link it shows a div above all other elements of my
page (a kind of popup). I would like to close it(hide the div again)
when the user clicks anywhere on the screen. How can i do that? The
'event listener' should only be activated if the div is visible.

<body onclick='if(thatDivDisplayBlock)thatDivDisplayNone ()'>
[please skip the signature in replies,
or have a decent newsreader do that automagically]
>--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[please do not toppost on usenet, corrected]
I can't access the body from my page as it is in a master page (i'm
doing asp.net). However I have a javascript function bodyLoad() which
is called at body load and in which I can do stuff. How can I assigne
the onclick event in this function ?
I would have no idea about "bodyLoad()": if this is asp.net, better ask
an asp.net group.

What is a master-page? Are you using iframes? Or is the <bodyset in a
include?

what about:

body.onload = myfunc; // Use no () !

function myfunc() {
if (thatDiv.display != 'none') // this line could be skipped ;-)
thatDiv.display = 'none';
};

not tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.