Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: screen redirect script based on aspect ratio

  1. #1
    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

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    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 } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    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?

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    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 } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    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>

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    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:

    so that when they click the full screen button on my flash,
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    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 08:49 PM.

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    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 } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 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>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    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 } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •