PDA

View Full Version : Screen Size Redirect Script



Neebski
02-22-2006, 08:23 AM
Okay the one I found here: http://www.dynamicdrive.com/dynamicindex9/info3.htm works great, the only thing im trying to do though is set it up so

users with a screen resolution larger than 800x600 go to the full size site
and every one else smaller than 800x600 will go to the mobile or small scaled down site.

anyone know how I might be able to modify this java script to fit what im looking for?

Thanks!!
-Kevin

jscheuer1
02-22-2006, 11:23 AM
It shouldn't be to hard, I bet you could do it if you just took a bit of time looking over the code. However, before you, I or anyone does it, I think you should decide where the 800x600 folks will be sent:


users with a screen resolution larger than 800x600 go to the full size site
and every one else smaller than 800x600 will go to the mobile or small scaled down site

gigabites
02-22-2006, 11:41 AM
It shouldn't be to hard, I bet you could do it if you just took a bit of time looking over the code. However, before you, I or anyone does it, I think you should decide where the 800x600 folks will be sent:LOL :D

@Neebski: Try this...



if (screen.width>800||screen.height>600) //larger than 800x600
window.location.replace("http://www.mysite.com/fullsize")

else if (screen.width<640||screen.height<480) //if smaller than 800x600
window.location.replace("http://www.mysite.com/reducedsize")

else if (screen.width==800||screen.height==600) //if 800x600 ;)
window.location.replace("http://www.mysite.com/normalsize")

Twey
02-22-2006, 04:25 PM
Yuck. Sending users to different pages based on screen size is a very bad idea. You can never anticipate every possible screen size and geometry.

Sending users to a different page based on whether they're using a mobile device or not, which is what the OP appeared to be intending, is a much better one. However, 800x600 is rather too large to be a boundary, I think.
if((screen.width + screen.height) < 800) window.location.replace("http://www.example.com/mobile/");Also, put that on your main page, so that non-Javascript browsers won't be left with an empty page.

Neebski
02-23-2006, 06:27 AM
so maybe, smaller than 500x yah??

I just threw out 800x600 just for an example

Twey
02-23-2006, 04:05 PM
Yes. My code will work reasonably well.
Ideally, this should be done server-side: WAP-enabled devices use a distinctive Accept header including several WAP- and WML-related filetypes.

Neebski
02-24-2006, 12:33 AM
right... I dont really think ill get that running soon :P

im just trying to figgure out this stuff haha

raicha
06-11-2012, 05:43 PM
Hello everyone,
can I put more than 4 criterias into the code. Means can I specify two more over 4 totalling 6 screen size criteria by adding following:

else if (screen.width==640||screen.height==480) //if 640x480
window.location.replace("http://www.microsoft.com")

with different height width. Please reply.

Thank you.