PDA

View Full Version : screen resolution script ---> need tweak plz



Mario_AU
02-16-2008, 05:46 AM
hello,


i'd like to ask some questions about the following script (http://www.dynamicdrive.com/dynamicindex9/info1.htm).

1.) you may have a spelling mistake. :D

Demo: This webpage is bested viewed with screen resolution 800*600. Your current resolution is 1920*1200. If possible, please change the resolution!


2.) can the script be tweaked to:
if user res = your recommended res then say:{custom}
if user res < your recommended res then say:{custom}
if user res > your recommended res then say:{custom}

is this possible ???

what i would like to actually have is for the script to only kick in if the user has a lesser resolution then what i put in the script as the preferred one and then recommend they change.


thanks....


____________________________________
Pimp of Mario's World. (http://www.taxi583.com) Hater of society.

jscheuer1
02-16-2008, 08:33 AM
You're right about the typo. If I could change it I would, but I don't have access to the library.

You've lost me here:



if user res = your recommended res then say:{custom}
if user res < your recommended res then say:{custom}
if user res > your recommended res then say:{custom}

If you only want the script to do anything when the user's res is lower (less) than the recommended, make these changes (red) in this line:


if (screen.width<correctwidth||screen.height<correctheight)

Mario_AU
02-16-2008, 09:13 AM
thanks that does improve it for me.

what i was demonstrating with my fake code was that i wish i could give a specific message to a user based on their actual resolution.

so if the script picks up a user as 800x600, i'd like to say something about that
and if a user has 1280x1024 (the most popular) i'd like to tell them something else. ..and so on. so i'd like to create a custom message for each resolution and display based on the user's resolution. for example to someone using 640x480 or 800x600 i'd ask them,"can you even see this site properly ? what are you using ? a mobile phone ?" and to the most popular screen res at the moment (based on many sites tracker stats) the 1280x1024, i'd say "what's that you're using there ? a 19" lcd ??? get with the times man. 20" & 22" lcd's sell below $199" or something like that!!! ;)

jscheuer1
02-16-2008, 09:49 AM
Yeah, I kinda got that while I was writing my response, but decided not to bother with it because it wasn't your main question. There are various ways this could be done. If you are still interested, here's one:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<div>
<script type="text/javascript">
function resMsg(){
var msg, res=screen.width+'x'+screen.height;
switch (res){

case '640x480':
msg="Message for 640x480";
break;

case '800x600':
msg="Message for 800x600";
break;

case '1024x768':
msg="Message for 1024x768";
break;

case '1280x1024':
msg="Message for 1280x1024";
break;

case '1440x900':
msg="Message for 1440x900";
break;

default:
msg="Nice "+res+" monitor!";
}

document.write(msg);
}
resMsg();
</script>
</div>
</body>
</html>