Forum Moderators: open

Message Too Old, No Replies

Redirect to different html depending resolution of visitor

different art pages setup for different resolutions

         

Sniper_E

8:14 am on Nov 26, 2003 (gmt 0)



I have three different html pages created where each show full screen pics, depended on the visitor's resolution.

I'm looking for a script that will read the resolution of a visitor and redirect them to a specifc html page.

Now, I have no idea how to write a redirect script.
But, this below will show you what I want it to do.

This is a simple redirect page:

<html><head>
<META HTTP-EQUIV="refresh" CONTENT="0; URL=page1.html"></head>
<body>
<center>please wait</body>
</html>

I want it to redirect depending on visitor's resolution.
Could you tell me how far off and wrong this is:

<html><head>
<script language="JavaScript">
function HTTP-EQUIV="refresh" CONTENT="0; {
var res = screen.width;
if(res<640){
URL=page1.html";
}
if(res=640){
URL=page2.html";
}
if(res=800){
URL=page3.html";
}
if(res=1024){
URL=page4.html";
}
}
</script>
</head>
<body>
<center>please wait</body>
</html>

See, I really don't know how to write a script.
Please guide me here. Thanks!

dcrombie

12:52 pm on Nov 26, 2003 (gmt 0)



Wow!

Get rid of HTTP-EQUIV. That code only works if it appears in the HTML document pre-JavaScript (not sure if writing the tag with document.write would work - someone will know).

Try something like:

<SCRIPT type="text/JavaScript">

var res = screen.width;

if (res >= 1024) self.location.href = "bigsite.html"; // or self.location.replace("bigsite.html");?!?
else if (res < 800) self.location.href = "smallsite.html";

</SCRIPT>

Note: screen.width is not available on all browsers. Also, quite a lot of your page can start to load before the redirect takes effect.