Make background clickable

K

Kristian

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
 
K

Kristian

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top