detect mouse click event

Discussion in 'Javascript' started by samuelberthelot@googlemail.com, Jul 7, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Evertjan. Guest

    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)
    Evertjan., Jul 7, 2006
    #2
    1. Advertising

  3. Guest

    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, 2006
    #3
  4. Evertjan. Guest

    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 <body> set 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)
    Evertjan., Jul 7, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davisro
    Replies:
    2
    Views:
    1,284
    Jim Corey
    Apr 23, 2004
  2. Jeff
    Replies:
    1
    Views:
    558
    Victor Bazarov
    Jan 11, 2005
  3. =?Utf-8?B?am9qb2Jhcg==?=
    Replies:
    1
    Views:
    4,059
    wwwtar
    Oct 2, 2006
  4. Kid Kid
    Replies:
    6
    Views:
    453
  5. Daniish
    Replies:
    2
    Views:
    221
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page