Trying to figure it out as I have a lot of widely different resultions according to google anayltics. And surprisingly 1680 is the most common on my site o_o.
I was told to use this:Code:
- <script language=Javascript>
- <!--
- var background
- if (screen.height == 1280) && (screen.width == 1024)
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1280.jpg";
- document.write (background);
- }
- elseif (screen.height == 1280) && (screen.width == 800)
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1280.jpg";
- document.write (background);
- }
- elseif (screen.height == 1680) && (screen.width == 1050)
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1680.jpg";
- document.write (background);
- }
- elseif (screen.height == 1440) && (screen.width == 900)
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1440.jpg";
- document.write (background);
- }
- elseif (screen.height == 1920) && (screen.width == 1080)
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1920.jpg";
- document.write (background);
- }
- else
- {
- background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1440.jpg";
- document.write (background);
- }
- -->
- </script>
But I don't understand code :X
All that's saying is that if a user has a certain resolution, that person sees a certain background image.
Why do you want a different background for different resolutions?
20% of my website's 10k viewers use 1680
20% use 1440
20% use 1280
:X
I'd recommend checking the size of the window rather than the size of the screen. Not everyone has their browser window maximised. Something like this (not fully tested)
<script type="text/javascript">
<!--
// List background images from the largest to the smallest
// For the width minus 20px or so to account for scrollbars
var bg_imgs = Array(
Array(1420, 'Image 1 URL'), // 1440
Array(1260, 'Image 2 URL'), // 1280
Array(1004, 'Image 3 URL') // 1024 // no comma on last line
);
var window_width = document.body.offsetWidth;
for(k =0; k<bg_imgs.length; k++) {
if(bg_imgs[k][0] <= window_width) {
document.body.style.backgroundImage = 'url('+ bg_imgs[k][1] +')';
break;
}
}
//-->
</script>