tags:

views:

608

answers:

4

I've been asked to make a sponsored background (site takeover) for one of our sites and the question arose of whether I can make the logos in the tiled background clickable.

My initial thought was 'no', but the more I think about it, the more I think it'd be possible if I either used JavaScript to make the body element clickable, or fake the background image as a layer below the content and make that clickable.

Has anyone done this before with success with one of these approaches or a different one?

jQuery:

$('body').click()

HTML:

<body>
  <div id="sponsors-div" style="position:fixed;z-index:0;"><a style="display:block;height:100%" href="http://sponsors.url"&gt;&lt;/a&gt;&lt;/div&gt;
  <div id="site-container" style="position:relative;z-index:1;">...
A: 

Why not make the background image into an image map, and bind a click event to each area:

$('#area51').click(function() {...
karim79
A: 

A click event on sponsors-div should work. Putting it on the body may affect other parts of the page (child elements of body).

Tom Clarkson
+3  A: 

You'd need to be careful around event order (event capturing vs. bubbling) differences between IE and Mozilla. If you have an element with an onClick event that essentially takes up the entire page, and then other clickable elements on "top" of it, clicking on one of those elements can cause BOTH events to fire, which is likely not the intended functionality.

PPK explains it better than I can.

Scottie
A: 

You can make a very large anchor tag and force body to hide the overflow, like this:

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

Gain some inspiration from this site: http://newline.dk/index.aspx

meep