PDA

View Full Version : newly created aspect ratio redirect script



kevin186
12-30-2007, 09:31 PM
<script language="JavaScript1.2">

/*Aspect Ratio Redirect Script (By kevin186 from www.marizs23.com and BLiZZaRD from www.dynamicdrive.com)*/

var e = (screen.height/screen.width)
if (e>.75)
window.location.replace("http://www.example.com/page1.htm")
else if (e<.75)
window.location.replace("http://www.example.com/page2.htm")
else if (e==.75)
window.location.replace("http://www.example.com/page3.htm")

</script>

*does not work if (else if (e=.75)) preceeds either the e>.75 or e<.75 statements.

pman
12-31-2007, 02:12 AM
[CODE]
*does not work if (else if (e=.75)) preceeds either the e>.75 or e<.75 statements.

You can't compare values using one "=" equal sign. Use "e==.75"

Just out of curiosity. What exactly are you trying to do? From the script it looks like if the user's screen size is different, you are redirecting them to a different page. Not sure why you would want to do something like that but try the above.

kevin186
12-31-2007, 04:58 AM
You can't compare values using one "=" equal sign. Use "e==.75"

Just out of curiosity. What exactly are you trying to do? From the script it looks like if the user's screen size is different, you are redirecting them to a different page. Not sure why you would want to do something like that but try the above.

thanks pman for that = really needed it. but maybe its hard for me to explain why i needed to do this, but i will try. i started making flash animations and such, and when i output the files i can set it to go 100% width and height. its really just some pictures slideshows. but the slideshow has an option to go full screen. so, i wanted to have the flash file created so that when full screen, it maximizes the use of the whole monitor. but not everybody has the same aspect ratio, the most common being 4:3 resultings from 1024x768. but i have 4 computers in my house, each with a diffent size aspect ratio. one hooked up to my webserver is 1024x768, one hooked up to my 57inch tv is 1128x664, and one computer upstairs is 1280x1024. i created 3 different versions of the same swf, each with the different size. so, now when i go to the site and go full screen, it is now set to mazimixe the full screen resolution because it leaves the browser when the button is pressed. and of course if the user has has javascript disabled they will just land on the page setup for 1024x768, which makes up 56% of the worlds resolution.

www.marizs23.com/futurama.html is my temporary example if u want to see what i mean. if ur monitor width/height ><=.75, then u will go to different page for each. change ur resolution to different aspect ratios and see what i mean.