Jump to content

First attempt at a screen matcher


zipster1967
 Share

Recommended Posts

Okay this is my first really worthwhile script and I am not sure if I am on the right track or way off the mark. I am trying to develop a splash screen that will display well in many different resolutions. My first thought was to load pages that were designed for each screen size by using the built in JavaScript window functions and this is what I wound up with. I haven't finished creating all the different index files but I figured there would be no sense building all those pages if this wasn;t going to display them anyway. So here is the heart and soul of my little script.This is the function my script calls.

function getWindowSize() {if (window.innerWidth) 	theWidth=window.innerWidth;else if (document.documentElement && document.documentElement.clientWidth)	 theWidth=document.documentElement.clientWidth;else if (document.body) 	theWidth=document.body.clientWidth;if (window.innerHeight) 	theHeight=window.innerHeight;else if (document.documentElement && document.documentElement.clientHeight)	 theHeight=document.documentElement.clientHeight;else if (document.body)	 theHeight=document.body.clientHeight;return [theWidth, theHeight]     }

I am hoping this will return the screen width and height and my script follows:

    <script src="javascript/stndlibrary.js">	var screendim=getWindowSize();	var screenwidth=screendim[0];	var screenlength=screendim[1];	var screenw=new array(640,800,1024,1280,1400,1600,2048); //Array for standard screen widths 	var screenh=new array(480,600,768,1024,1050,1200,1536);  //Array for standard screen heights	var indexfilename=new array('vga','svga','xga','sxga','sxgap','uxga','qxga'); //Array for file-names for different pages for each screen size	for (i=0;i<=6;i++);	}	if (screenwidth <= screenw[i]) && (screenlength <= screenh[i]);	  {	    window.location.replace('http:\\perezcomputer.com\'+indexfilename[i]+'index.html');	    break;	  }	}	</script>

Any hints or suggestions would be appreciated. I am quite new to JavaScript so I am taking baby steps so I don;t fall on my face.

Link to comment
Share on other sites

that seems like a lot of work. creating a unique index page for multiple resolutions? why not just CSS with relative widths? and min/max widths/heights to define the frame?

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
 Share

×
×
  • Create New...