...

View Full Version : Generic screen resolution redirect



icradz
12-22-2003, 08:11 AM
I have the following screen resolution redirection script:

var correctwidth=1024
var correctheight=768

if (screen.width<correctwidth||screen.height<correctheight)
location.href="index8.html";

The above works just fine, the only thing I don't like about it is that it's not generic which does not allow me to place it in a js file and point every page at it. I would like to enhance the above code to make it generic. To help the process my 800x600 pages are named the same as the 1024x768 pages but with an 8 added on. So, in the above example my 1024x768 home page file name is index.html, and the corresponding 800x600 home page is named index8.html.

What I need the script to do is redirect the user to a page with a name that matches that which was actually requested but with an 8 added at the back (ie index8.html if index.html was requested). If it makes things easier I could differentiate the files using extension type (eg .html for 1024x768 pages and .htm for 800x600 pages), in which case if index.html was requested the user would be redirected to index.htm.

Could someone please help me make code at the top generic using one of the methods described above.

Thanks

icradz

Roy Sinclair
12-22-2003, 11:05 PM
And what would your script do when I visit it using 1280x1024?

The fallicy of fixed size web pages is still going to trip you up and oh yeah, while my monitor is 1280x1024, I run the web page at a smaller size (not full-screen). Oh wait again! I like your page so much that I want to check up on it when I'm not at my computer, I'll use my PDA but it has a 300x200 screen on it.

You can't please everyone all the time but you really, really need to look at if or how you can make your web page work ok regardless of the user's resolution just to save yourself the work of creating endless copies of the page to match the various screen resolutions users will hit you with.

icradz
12-23-2003, 07:29 AM
Roy,

Thanks for the feedback. With your higher resolution you'll simply get the 1024x768 version. There is no way I would attempt to cover all the resolutions uisng this method. The most popular ATM (1024x768 and 800x600) will do. I've read up on liquid page design and whilst it sounds really warm and fluffy I think it's a complete falasy that you can get your site looking exactly the way you want in all the resolutions!

So, back to the question at hand, can the script I posted earlier be made generic?

Cheers

icradz

Kor
12-23-2003, 09:15 AM
I think I got your point. You need to find the path name of the page, and change it when redirect. Use the

self.location.pathname

reference to get the pathname of your page. The result is a string which you can manipulate using usual string methods, for instance split()....

Is it this information enough to you?

brothercake
12-23-2003, 11:17 AM
Originally posted by icradz
I've read up on liquid page design and whilst it sounds really warm and fluffy I think it's a complete falasy that you can get your site looking exactly the way you want in all the resolutions!
Nobody's saying that. The real fallacy is that you can get your site looking exactly the way you want in *any* resolution - it will *never* look to others how it looks to you, and it doesn't have to - a well made site is not one that looks the same to all, it's one that is useable by all regardless of the device used to access it.

Nonetheless, if your design benchmarks are 800x600 to 1024x768 you shouldn't have trouble making a design fluid within those constraints.

It's up to you of course, but your current path will cause you nothing but grief, and eventually you'll abandon it. May as well save yourself the pain.

Kor
12-23-2003, 11:54 AM
There is no way I would attempt to cover all the resolutions uisng this method.


Yes, but you actually can cover all the resolution using, as Roy and brothercake well said, liquid design techniques (% dimensions, relative position, using screen.availWidth and screen.availHeight and so on....)...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum