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
I wrote a solution for this since I couldn't find a complete one that was cross-browser. It is designed to host and display a clickable sponsor background across a network of sites.
Put this code into a js file and host it on a central domain:
$(function () {
//** change these values to your own
var bg_ad_css = "url(http://cdn.my-domain.com/sponsor-bg.jpg) no-repeat center top #ffffff";
var bg_ad_url = "http://www.sponsor-website.com/";
//**
var bg_ad_anchor = $(document.createElement("a"));
bg_ad_anchor.css({ display: "block", position: "absolute", "z-index": 0, top: 0, left: 0, width: $(window).width(), height: $(window).height() });
bg_ad_anchor.attr("target", "_blank").attr("href", bg_ad_url);
$(window).resize(function () {
if (bg_ad_anchor) {
bg_ad_anchor.css({ width: $(window).width(), height: $(window).height() });
}
});
if (window._bg_ad) {
for (var i = 0; i < _bg_ad.contentWrappers.length; i++) {
var element = _bg_ad.contentWrappers[i];
$(element.selector).css({ position: "relative", "z-index": element.zIndex == undefined ? 1 : element.zIndex });
}
}
$("body").css({ "background": bg_ad_css }).append(bg_ad_anchor);
});
Then use it like so in one or many websites: