View Full Version : Help modifying a script

09-25-2005, 04:02 AM

Is there any way this script (screen resolution redirect) can be altered to modify the text size based on the users screen resolution, instead of moving the user to a different page... similar to the way the document text sizer does below?



FYI: The page that I want to affect is the bottom frame shown here:

09-25-2005, 06:01 AM
You should be able to just install both scripts on the page. Put the text sizer script first on the page (above the screen res detector), so that its functions will be available to the screen res detector. Then modify the screen res detector substituting:



return;for the statements like this one:

window.location.replace("http://www.netscape.com")The first one makes text larger, the second makes it small. Using 'return;', won't do anything at all except exit the script but, might be just the ticket for certain resolutions. Also, if you need things to get even bigger use:

onload=function(){ts('body',2)}I think you can see that using -2 will then make things even smaller than -1. There are limits to how large/small a number you can use but 3 and -3 should be OK too, if you need them. Beyond that, the change in text size would probably be too great for any practical use.

One other thing, the text sizer script can be touchy. Install it alone on the page first to see if it is compatible with your markup.

09-25-2005, 05:57 PM
Thanks! This works perfectly. I have applied the script's to the page and modified the graphics a bit to make the picture look ok but it works great!

Question... is there an entry that I could use that would specify if the screen size isn't shown then just use the default size specified in the html code?

09-25-2005, 06:31 PM
That would be here:

else //if all else
window.location.replace("http://google.com") You could change it to:

else //if all else
return;Or just eliminate the two lines altogether. Either way, screen resolutions not detected would serve the page 'as is'. There are a couple of problems though. What browser are you using? In FF it looked and worked well but, in IE it throws an error on:

if (screen.width==800||screen.height==600) //if 800x600
onload=function(){ts('body',1.5)}I'm pretty sure that it is the 1.5 that it doesn't like. Just 1 would probably be OK. Also, using 2 for the font size in IE seems a bit big (but, not out of the question) at 1024x768 resolution (fine in FF).

Generally, it is best to let surfers use their own resolutions though. Typically, in IE with a 800x600 resolution, folks are already surfing at -1 (smaller on their 'view menu') font size. It is the default for browsers installed on machines with that resolution. Similarly for other browsers but, in that case users have generally set their own preferred font size as, these other browsers are almost always add-ons.

09-25-2005, 10:39 PM
I'm using IE. Both resolutions seem to look ok on my end

The purpose is to try and make the page look "similar" in both of the major resolutions without creating two entirely separate pages. In this way I can be sure that if I add text in 800 x 600 then it will also look the same in 1024 x 768, or at least close enough that I wouldn't have to redesign two pages.

I thought about making everything smaller, but any pictures or graphics that I would add would be so small at 1024 x 768 that there would almost not be a point in adding them.

If you have any suggestions I would love to hear them.

09-25-2005, 10:57 PM
My thought is that the page will look similar in all resolutions if the users having those resolutions have their browsers configured in a sensible fashion, which is much more often the case than not. By taking matters into your own hands, the majority of users not using the resolution you designed the page for will see either text that is too large or too small. Additionally, there are many other resolutions out there. Due to these facts, I would never do something like this for a professional job unless the client demanded it over my repeated objections. I apologize for not pointing this out in the first place but, my initial reaction is usually not to question what people want or why they want it. I would suggest just letting the page be however it will be and not bothering with these two scripts.