Screen Res and Redirecting

javascript United States
  • 18 years ago

    How do i do this in JavaScript


    if Screen.Width < 1024 then goto Small.html else goto Large.html


    ie: redirect to one page if the screen resolution is <1024 or redirect to another page if screen resolution greater > 1024


    ??


    also: how do i check the value of an object:  ie If Object1.value="hello" then alert("Crap Cakes")


  • 18 years ago

    Welcome back
    Got this from javascript.internet.com ....

    Code:

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function redirectPage() {
    var url640x480 = "http://www.yoursite.com/640x480";
    var url800x600 = "http://www.yoursite.com/800x600";
    var url1024x768 = "http://www.yoursite.com/1024x768";
    if ((screen.width == 640) && (screen.height == 480))
    window.location.href= url640x480;
    else if ((screen.width == 800) && (screen.height == 600))
    window.location.href= url800x600;
    else if ((screen.width == 1024) && (screen.height == 768))
    window.location.href= url1024x768;
    else window.location.href= url640x480;
    }
    // End -->
    </script>

  • 18 years ago

    Quote:

    also: how do i check the value of an object:  ie If Object1.value="hello" then alert("Crap Cakes")


    in javascript this would be


    if (object1.value=="hello")
      alert("Crap Cakes");


    given that you know that name of the object. if it is buried within other objects (e.g. a form) or the name might change then the code would look different.



Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Brevity is the soul of wit” - Shakespeare