Jump to content

[WPI Theme] Multiple Wallpaper


Recommended Posts

Hi all,

I created the following code in my wpi.html file. Could someone re-write it better? :whistle:

Not all screen resolutions are included. And a 'backup' wallpaper would be nice too...

Main reason for this. Wallpapers get out of proportion and if upscaled you have often granular fonts, ugly to read..

Thanks in advance

HJW

<img id='bgpic' src='' width="100%" height="100%">
</div>
<script type="text/javascript">
if ((screen.width==1920) && (screen.height==1200))
document.all.bgpic.src = "./Themes/vista/wallpaper1920ws.jpg";
</script>
<script type="text/javascript">
if ((screen.width==1600) && (screen.height==1200))
document.all.bgpic.src = "./Themes/vista/wallpaper1600.jpg";
</script>
<script type="text/javascript">
if ((screen.width==1600) && (screen.height==1050))
document.all.bgpic.src = "./Themes/vista/wallpaper1600ws.jpg";
</script>
<script type="text/javascript">
if ((screen.width==1280) && (screen.height==1024))
document.all.bgpic.src = "./Themes/vista/wallpaper1280.jpg";
</script>
<script type="text/javascript">
if ((screen.width==1024) && (screen.height==768))
document.all.bgpic.src = "./Themes/vista/wallpaper.jpg";
</script>

Link to comment
Share on other sites


I created the following code in my wpi.html file. Could someone re-write it better? :whistle:

Not all screen resolutions are included. And a 'backup' wallpaper would be nice too...

You need to have a default or as you say 'backup' wallpaper so that the user doesn't have a blank screen if they do not have one of your defined resolutions. Additionally, you can move all of this into one script tag. Here's what I've come up with:

<img id='bgpic' src='./Themes/vista/defaultwallpaper.jpg' width="100%" height="100%">
</div>
<script type="text/javascript">
switch(screen.width) {
case 1920:
if(screen.height==1200) {
document.all.bgpic.src = "./Themes/vista/wallpaper1920ws.jpg";
}
break;
case 1600:
if(screen.height==1200)) {
document.all.bgpic.src = "./Themes/vista/wallpaper1600.jpg";
} else if(screen.height==1050) {
document.all.bgpic.src = "./Themes/vista/wallpaper1600ws.jpg";
}
break;
case 1280:
if(screen.height==1024) {
document.all.bgpic.src = "./Themes/vista/wallpaper1280.jpg";
}
break;
case 1024:
if(screen.height==768) {
document.all.bgpic.src = "./Themes/vista/wallpaper.jpg";
}
break;
}
</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...