Go Back   Dynamic Drive Forums > General Coding > Looking for such a script or service
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 12-30-2007, 02:27 AM
kevin186 kevin186 is offline
Junior Coders
 
Join Date: Dec 2007
Location: chicago
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default screen redirect script based on aspect ratio

hello please help me. i cant find this anywhere and dont know if its possible. i need to redirect users to different pages on my websites based on the aspect ratio of their resolution. i am using flash for my sites which will max out at 100% of width and height. so, i want to redirect to the version of the page that will best suit them, with 2 different versions based on 4:3 and 16:9, so that when they click the full screen button on my flash, it will fill their monitor fully. i could do this with the regular Screen Size Redirect Scripthttp://www.dynamicdrive.com/dynamicindex9/info3.htm , but i would have to input so many different screen resolutions just to make sure i am covered. i would like to just have a function that takes screen.width divided by screen.height and compares it to my ratios of being > < = 4:3 or 16:9

thanks
Reply With Quote
  #2  
Old 12-30-2007, 02:16 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,476
Thanks: 3
Thanked 105 Times in 104 Posts
Blog Entries: 1
Default

Why don't you just do it all in Flash?

stage.height and width will return a value, based on that value you can load movie1 or movie 2.

Seems a little easier than all that you said.

OR, you could just make 2 links, one for each aspect ratio. Let the user click on the one they want.
__________________
{CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
Follow Me on Twitter: @Negative_Chaos
PHP Code:
$result mysql_query("SELECT finger FROM hand WHERE id=3");
echo 
$result
Reply With Quote
  #3  
Old 12-30-2007, 05:18 PM
kevin186 kevin186 is offline
Junior Coders
 
Join Date: Dec 2007
Location: chicago
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Question

Quote:
Originally Posted by BLiZZaRD View Post
Why don't you just do it all in Flash?

stage.height and width will return a value, based on that value you can load movie1 or movie 2.

Seems a little easier than all that you said.

OR, you could just make 2 links, one for each aspect ratio. Let the user click on the one they want.
thanks for your reply. unfortunately i dont have the skills for actionscript or javascript. i am just new in the game and i am as self taught as time allows. the link idea is simple, but not what i came for. i dont mean to be unappreciative, but i really want to do it with the javascript. is there no way to modify the Screen Size Redirect Script to perform the math of dividing width into height and then to compare it to a number? probably simple for you, but i just dont know anything about javascript. i tried to modify the code myself, but cant figure what variables and commands are needed by javascript. can you solve my mental anguish so that i dont have to learn javascripting right now just to create a simple script? as far as i know, this screen redirect does not exist, dont you want to be the first one to do it?
Reply With Quote
  #4  
Old 12-30-2007, 05:34 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,476
Thanks: 3
Thanked 105 Times in 104 Posts
Blog Entries: 1
Default

So right now you have 2 swf files yes? one for 4:3 and one for 16:9, correct?

And you want something that will find the aspect ratio of the users computer, and based on that match them with the correct swf for them to view?

If that is correct, then tell me the following:

1) Names of the 2 Flash files you are using.
2) Version of Flash you are using (7, 8, 9or MX, MX 2004, CS3)
3) When you need it by

__________________
{CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
Follow Me on Twitter: @Negative_Chaos
PHP Code:
$result mysql_query("SELECT finger FROM hand WHERE id=3");
echo 
$result
Reply With Quote
  #5  
Old 12-30-2007, 05:57 PM
kevin186 kevin186 is offline
Junior Coders
 
Join Date: Dec 2007
Location: chicago
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by BLiZZaRD View Post
So right now you have 2 swf files yes? one for 4:3 and one for 16:9, correct?

And you want something that will find the aspect ratio of the users computer, and based on that match them with the correct swf for them to view?

If that is correct, then tell me the following:

1) Names of the 2 Flash files you are using.
2) Version of Flash you are using (7, 8, 9or MX, MX 2004, CS3)
3) When you need it by

you are correct, although i didnt created the second file yet until i was able to first redirect it. but i can easily create the second one.

and yes i do want to detect the aspect ratio so that they are matched with the correct swf.

1)futurama4x3.swf, futurama16x9.swf (generic examples of names)
2) CS3
3) no real due date, this is just for fun

i tried to edit that screen redirect script, but i really am not sure about the language. my code below didnt work, but i really didnt expect it to:

<script language="JavaScript1.2">

if (screen.height/screen.width<.75) //if <4:3
window.location.replace("http://www.example.com/page1.htm")

else if (screen.height/screen.width>.75) //if >4:3
window.location.replace("http://www.example.com/page2.htm")

else if (screen.height/screen.width=.75) //if =4:3
window.location.replace("http://www.example.com/page3.htm")

</script>
Reply With Quote
  #6  
Old 12-30-2007, 06:06 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,476
Thanks: 3
Thanked 105 Times in 104 Posts
Blog Entries: 1
Default

We will just do it all internally in Flash (Easy, don't freak out )

I will match your devices, but it will have to wait, as I don't run CS3 at work. When I get home I will work on a couple of examples for you.

Hopefully with luck, I can just provide you with a little piece of AS to place on the "full screen" button you have:

Quote:
so that when they click the full screen button on my flash,
__________________
{CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
Follow Me on Twitter: @Negative_Chaos
PHP Code:
$result mysql_query("SELECT finger FROM hand WHERE id=3");
echo 
$result
Reply With Quote
  #7  
Old 12-30-2007, 06:30 PM
kevin186 kevin186 is offline
Junior Coders
 
Join Date: Dec 2007
Location: chicago
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Talking

the full screen button is part of the SlideShowPro component, i am not sure if that can be edited. is there any way to have that javascript do a redirect based on the math of width divided by height, or is that out of the scope of what javascript can do? and why the hell are you working on a sunday? watch some cartoons

Last edited by kevin186; 12-30-2007 at 07:49 PM.
Reply With Quote
  #8  
Old 12-30-2007, 06:56 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,476
Thanks: 3
Thanked 105 Times in 104 Posts
Blog Entries: 1
Default

well, you could try something like the following:

Code:
var e=(screen.width/screen.height);
if (e=1.66){
window.location.replace("http://www.example.com/page2.htm");
else{
window.location.replace("http://www.example.com/");
}
and just add an if for each major aspect ratio (I think there are 6 or 7) umm.. 1.33, 1.37, 1.66, 1.78, 1.85 and 2.35 are the ones I know off the top of my head.

Just make sure the JS is correct, as I am not much help on JS yet. (But I am learning it)
__________________
{CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
Follow Me on Twitter: @Negative_Chaos
PHP Code:
$result mysql_query("SELECT finger FROM hand WHERE id=3");
echo 
$result
Reply With Quote
  #9  
Old 12-30-2007, 07:16 PM
djr33's Avatar
djr33 djr33 is offline
Global Moderator
 
Join Date: Mar 2006
Location: N. California, USA
Posts: 8,300
Thanks: 57
Thanked 343 Times in 339 Posts
Default

Your reasoning makes sense, but there's a flaw.

Not everyone, in fact it may be rare that anyone has the browser maximized. So any screen, regardless of dimension may be any width or height, within the maximum dimensions of the monitor.

There are not simply 16:9 and 4:3 monitors, but, then, any aspect ratio of windows.

You would be best off, probably, running it as a choice, or perhaps with an autodetect within flash, to guess which is closest.

Really though I'd just pick one and let people deal with it. If someone had a widescreen monitor, pillarboxing won't be all that stunning. And if you are making something intended to feel like a film, well, go widescreen, and letterbox for the 4:3 monitors and they'll not only be accepting of it, but most people will probably think it's cool, that "film look".


Blizzard, those do seem about accurate for common ratios, though it's futile to try and list them all because they vary, especially from country to country.
__________________
Daniel - Freelance Web Design | <?php?> | <html>| Ich kann Deutsch. | Capisco l'italiano. | Estudio español. | Estudava português. | un peu de français | 日本語の学生です。| درست العربية
Reply With Quote
  #10  
Old 12-30-2007, 07:23 PM
BLiZZaRD's Avatar
BLiZZaRD BLiZZaRD is offline
Elite Coders
 
Join Date: Aug 2005
Location: Other Side of My Monitor
Posts: 3,476
Thanks: 3
Thanked 105 Times in 104 Posts
Blog Entries: 1
Default

True. Another option would be instead of finding aspect ratio find the view point (browser window size) and based on that use >= or <= to go to the desired movie.

Code:
<script type="text/javascript">
<!--

 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');
//-->
</script>
__________________
{CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
Follow Me on Twitter: @Negative_Chaos
PHP Code:
$result mysql_query("SELECT finger FROM hand WHERE id=3");
echo 
$result
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:50 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.