Make background clickable

Discussion in 'Javascript' started by Kristian, Jan 5, 2007.

  1. Kristian

    Kristian Guest

    Hey there,

    On my page, i want to make my entire body background clickable without
    disturbing my content area in my main div.

    I tried putting a clickable div behind it all with a low z-index, but
    that solution did not work out ...

    Does anyone knows a solution to that?

    Best regards,
    Kristian
    Kristian, Jan 5, 2007
    #1
    1. Advertising

  2. Kristian

    Kristian Guest

    I came about something like this:


    -------------------------------------------------------

    <script>
    function clickBg(e) {
    evt = e || window.event;
    if (e.target) targ = e.target;
    else if (e.srcElement) targ = e.srcElement;
    if (targ.nodeType == 3) // Safari bug
    targ = targ.parentNode;

    if (targ.id == 'body') {
    window.open('http://example.com/');
    }

    </script>

    </head>
    <body onclick="clickBg(event);" id="body">

    -------------------------------------------------------

    I havent figured out how to control the cursor-style in different
    browsers, but maybe i'll find a way :)

    /kristian
    Kristian, Jan 5, 2007
    #2
    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. RJN
    Replies:
    1
    Views:
    1,924
    =?Utf-8?B?U2NvdHQgU2ltb25z?=
    Sep 27, 2004
  2. Paul W
    Replies:
    9
    Views:
    660
    Alex Homer
    Oct 3, 2004
  3. mi
    Replies:
    4
    Views:
    13,453
    dorayme
    May 21, 2008
  4. mogwaii
    Replies:
    9
    Views:
    2,521
    mogwaii
    Dec 8, 2010
  5. Replies:
    2
    Views:
    115
Loading...

Share This Page