vForums Support Banner


Visit Base Classics - Gaming Chairs

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Different Background Images for resoultions - View Topic
Topic Rating: *****
Printable View
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 35
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
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:
 
  1. <script language=Javascript>
  2. <!--
  3. var background
  4. if (screen.height == 1280) && (screen.width == 1024)
  5. {
  6. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1280.jpg";
  7. document.write (background);
  8. }
  9. elseif (screen.height == 1280) && (screen.width == 800)
  10. {
  11. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1280.jpg";
  12. document.write (background);
  13. }
  14. elseif (screen.height == 1680) && (screen.width == 1050)
  15. {
  16. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1680.jpg";
  17. document.write (background);
  18. }
  19. elseif (screen.height == 1440) && (screen.width == 900)
  20. {
  21. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1440.jpg";
  22. document.write (background);
  23. }
  24. elseif (screen.height == 1920) && (screen.width == 1080)
  25. {
  26. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1920.jpg";
  27. document.write (background);
  28. }
  29. else
  30. {
  31. background = "http://novogradtimes.com/wp-content/themes/arras-theme/images/backgrounds/1440.jpg";
  32. document.write (background);
  33. }
  34. -->
  35. </script>
 


But I don't understand code :X
Kronus
Junior Member
**

[Avatar]

Posts: 45
Status: Offline
Gender: Male
Location: United States
Age: 35
Joined:  
Reputation: 0%  


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. {Tongue Out}

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
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
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
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 35
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
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
*****

[Avatar]

Posts: 3,709
Status: Offline
Gender: Male
Age: 8 11
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
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>


Image
 Printable View

All times are GMT+0 :: The current time is 4:49pm
Page generated in 0.5923 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums