Connecting Tech Pros Worldwide Help | Site Map

detect mouse click event

samuelberthelot@googlemail.com
Guest
 
Posts: n/a
#1: Jul 7 '06
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

Evertjan.
Guest
 
Posts: n/a
#2: Jul 7 '06

re: detect mouse click event


wrote on 07 jul 2006 in comp.lang.javascript:
Quote:
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)
samuelberthelot@googlemail.com
Guest
 
Posts: n/a
#3: Jul 7 '06

re: detect mouse click event


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:
Quote:
wrote on 07 jul 2006 in comp.lang.javascript:
>
Quote:
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)
Evertjan.
Guest
 
Posts: n/a
#4: Jul 7 '06

re: detect mouse click event


wrote on 07 jul 2006 in comp.lang.javascript:
Quote:
Evertjan. wrote:
>
Quote:
>wrote on 07 jul 2006 in comp.lang.javascript:
>>
Quote:
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]
Quote:
Quote:
>--
>Evertjan.
>The Netherlands.
>(Please change the x'es to dots in my emailaddress)
[please do not toppost on usenet, corrected]
Quote:
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)
Closed Thread