Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save matharchod/1304747 to your computer and use it in GitHub Desktop.
Save matharchod/1304747 to your computer and use it in GitHub Desktop.
A script that uses core JavaScript & jQuery to change the BODY background image and add a transparent link over the background of the page.
//Ad SKINS
function loadAdSkinBkg(bgrnd_skin_bgColor,bgrnd_skin_imageSrc,bgrnd_skin_linkTarget){
$('body','html').css({"background-image":"none","background-color":bgrnd_skin_bgColor});
$('body','html').css({"background-image":bgrnd_skin_imageSrc, "background-position":"center top","background-repeat":"no-repeat"}).prepend('<a id="skin_background" href="'+ bgrnd_skin_linkTarget+'" target="_blank">&nbsp;</a>');
$.getDocHeight = function(){
return Math.max(
$(document).height(),
$(window).height(),
document.documentElement.clientHeight
);
};
var bgrnd_link_height = $.getDocHeight;
$("#skin_background").css({"height":bgrnd_link_height});
}
function skin_background(){
if (bgrnd_skin_linkTarget == "" || bgrnd_skin_bgColor == "" || bgrnd_skin_imageSrc == "") {
null;
}
else {
loadAdSkinBkg();
}
}
@timeismoney1
Copy link

Hello,
Thanks for the awesome script. I have been trying to get this code to to work, I can't figure it out. Which jquery build are you using. I have no idea of what i'm doing. Below is the code i'm using can you instruct me on getting to work correctly.

Thanks.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript"> var bgrnd_skin_bgColor = #FF0000; var bgrnd_skin_imageSrc = XXLfrosh11-wallpaper.jpg; var bgrnd_skin_linkTarget = http://mydailyhustle.com; //Ad SKINS function loadAdSkinBkg(bgrnd_skin_bgColor,bgrnd_skin_imageSrc,bgrnd_skin_linkTarget){ $('body','html').css({"background-image":"none","background-color":bgrnd_skin_bgColor}); $('body','html').css({"background-image":bgrnd_skin_imageSrc, "background-position":"center top","background-repeat":"no-repeat"}).prepend(' '); $.getDocHeight = function(){ return Math.max( $(document).height(), $(window).height(), document.documentElement.clientHeight ); }; var bgrnd_link_height = $.getDocHeight; $("#skin_background").css({"height":bgrnd_link_height}); } function skin_background(){ if (bgrnd_skin_linkTarget == "" || bgrnd_skin_bgColor == "" || bgrnd_skin_imageSrc == "") { null; } else { loadAdSkinBkg(); } } </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment