Created
October 21, 2011 19:43
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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"> </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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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>