getting client's screen resoultion.....

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

getting client's screen resoultion.....

Post by dull1554 »

I was wondering if anyone knew of a way to check the screen resoultion on the client side. I'm guessing you can't do this with php (ya know the whole server side limitation thing), i was wondering if you could with js?!?!?!?!

wanted to have several different pages, and load a different one depending on the clients resoultion...

THANKS IN ADVANCE
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Client-side.

On your index page use JavaScript to grab the screen resolution and then auto-redirect the browser to another page.

Code: Select all

<head>
<script type="text/javascript">
var w = screen.availWidth;
var h = screen.availHeight;

var goto = "anotherPage.php?width="+w+"&height="+h;

if(document.images)
&#123;
    window.location.replace(goto);
&#125;
else
&#123;
    window.location = goto;
&#125;

</script>
</head>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

thanks a million.....i hate having those corny....This page designed for 800X600.....and what not......but thanks Master Gen-ik....GOD I LOVE THIS PLACE
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

:) No probs mate.
Post Reply