SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast snorky's Avatar
    Join Date
    Jul 2003
    Location
    Great Northwet
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script to select screen size

    My target audience is very diverse. As a result, I get a lot of gripes about the sites. I tried to address one of those gripes, with mixed results.

    I want to give the user the ability to select the screen size. Here's how I did it:

    In the <HEAD> section:

    <SCRIPT language="javascript1.2" type="text/javascript">
    <!--
    function resizeIt800()
    {
    self.resizeTo(800,600);
    }

    function resizeIt1024()
    {
    self.resizeTo(1024,768);
    }

    function resizeIt1280()
    {
    self.resizeTo(1280,1024);
    }
    //-->
    </SCRIPT>

    In the <BODY>:

    <A HREF="javascript:" onClick="resizeIt800()">800 x 600</A><BR>
    <A HREF="javascript:" onClick="resizeIt1024()">1024 x 768</A><BR>
    <A HREF="javascript:" onclick="resizeIt1280()">1280 x 1024</A><BR>

    This works in Firefox 2.x and IE 7.x
    It does not work in IE 6.0. ( In IE 6, clicking the link does nothing )

    My Questions:
    1. How do I tweak the script so that it works in those 3 browsers?
    2. Is there a better way to accomplish this task?
    Snorky
    Bless the little children while they're still too young to hate.
    - Tom T. Hall

  2. #2
    SitePoint Addict
    Join Date
    Feb 2005
    Location
    Brisbane, Australia
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    HTML Code:
    <a href="javascript:resizeIt1280()">

  3. #3
    SitePoint Wizard bronze trophy bluedreamer's Avatar
    Join Date
    Jul 2005
    Location
    Middle England
    Posts
    3,372
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You might be better off using switchable style sheets? - http://alistapart.com/stories/alternate/

  4. #4
    SitePoint Enthusiast snorky's Avatar
    Join Date
    Jul 2003
    Location
    Great Northwet
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheAnarchist View Post
    Try:
    HTML Code:
    <a href="javascript:resizeIt1280()">
    THX. The script now behaves on all three browsers IFF* the video card and monitor resolution support the screen size that the user selects.

    Gee, that was so easy, let's try another, related, issue:

    How to I help the user change either screen resolution, or text size, or both?


    * IFF == "IF and ONLY IF". I learned that in either some math class or some logic class - all of which are several decades in the past....
    Snorky
    Bless the little children while they're still too young to hate.
    - Tom T. Hall

  5. #5
    code ninja hamstu's Avatar
    Join Date
    Nov 2002
    Location
    Montréal, Canada
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The easiest way for you to change text size would be to do some stylesheet switching. Check out this article: http://www.alistapart.com/articles/bodyswitchers/

    As for screen resolution, you can't do that yourself. And even if you could, I wouldn't recommend it. The only way is for the user to change it themselves.

  6. #6
    SitePoint Enthusiast snorky's Avatar
    Join Date
    Jul 2003
    Location
    Great Northwet
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bluedreamer View Post
    You might be better off using switchable style sheets? - http://alistapart.com/stories/alternate/
    hmmmm....... Now I remember why we use forums to find answers - or to remind us of answers we should have known before asking.......



    THX - for the whack upside the head
    Snorky
    Bless the little children while they're still too young to hate.
    - Tom T. Hall

  7. #7
    SitePoint Member getskay's Avatar
    Join Date
    Apr 2007
    Location
    Jordan
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool man
    but tis script change the size of browser window only in FireFox and its not worke even on IE 7
    To be or Not to Be Depends on Chosen ur Way
    =======================================
    When the life goes bad... Remember it may go worse


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
  •