ashkir Full Member
Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 35 Joined:
pmskypemsnyahoo | Different Background Images for resoultions (22nd Mar 10 at 10:25pm UTC) | | 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 | |
|
Kronus Junior Member
Posts: 45 Status: Offline Gender: Male Location: United States Age: 35 Joined:
pmmsnxfire | Re: Different Background Images for resoultions (23rd Mar 10 at 1:39am UTC) | | All that's saying is that if a user has a certain resolution, that person sees a certain background image. | |
Quote: Cr0w [www.cr0wonline.com] says: But if you have an id of "pen", and you have "penis" in a code name, it'll mess it up. Cr0w [www.cr0wonline.com] says: Damn those penises messing things up. |
|
Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Different Background Images for resoultions (23rd Mar 10 at 2:13am UTC) | | Why do you want a different background for different resolutions? | |
|
ashkir Full Member
Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 35 Joined:
pmskypemsnyahoo | Re: Different Background Images for resoultions (23rd Mar 10 at 10:35pm UTC) | | 20% of my website's 10k viewers use 1680
20% use 1440
20% use 1280
:X | |
|
Ross Administrator
Posts: 3,709 Status: Offline Gender: Male Age: 8 1⁄1 Joined:
Additional Groups: Support Team
pmwwwgtalkvForum | Re: Different Background Images for resoultions (23rd Mar 10 at 11:08pm UTC) | | 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>
| |
|
|