+ Reply to Thread
Results 1 to 7 of 7

Thread: JavaScript:Tutorial, Screen Resolution

  1. #1
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6

    JavaScript:Tutorial, Screen Resolution

    Introduction:-
    This is a simple tutorial.. It will get the screen resolution and if you modify it a little bit you can use it to define how your website will be displayed like for example having to home pages then if the screen resolution is 1024x768 it will display index1.html and if the user has 800x600 it will display index2.html.. but then thats up to you in this tutorial I will keep it the simplest possible.

    Solution:-
    This goes between <head> tags:-
    Code:
    <script language="JavaScript">
    function res() 
    {
    alert('Screen Resolution Is '+screen.width+' by '+screen.height);
    }
    </script>
    And this as the body code

    Code:
    <body onLoad='res()'
    Explanation:-
    Can it be simpler than that?

    A Preview:-
    None

    Conclusion:-
    As Always Feedback is welcome and the full source is attached!!
    Attached Files

  2. #2
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25
    nice, i know nothing about JavaScript but i have 2 noobie questions.

    1) How would you calculate 90% of the screen width? Could you just do it like
    Code:
    alert('Screen Resolution Is '+screen.width*.9+' by '+screen.height);
    lol?

    2) Also since i guess res() returns two values would it be possable to use screen.width as like a varible? say
    Code:
    <table width='screen.width'><tr><td>blah></td></tr></table>
    again dont laugh at me, i know nothing about JS

  3. #3
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6
    Quote Originally Posted by Sidewinder View Post
    1) How would you calculate 90% of the screen width? Could you just do it like
    Code:
    alert('Screen Resolution Is '+screen.width*.9+' by '+screen.height);
    Yes thats it
    2) Also since i guess res() returns two values would it be possable to use screen.width as like a varible? say
    Code:
    <table width='screen.width'><tr><td>blah></td></tr></table>
    Yes you can use it as a variable for example:-
    Code:
    <body>
    <script language="JavaScript">
    window.open('about:blank','window name','width=screen.width,height=200');
    </script>
    </body>
    This will open a new window with the width of the screen resolution using screen.width directly and height of 200
    Or you can declare screen.width as a variable and then use the variable like this:-
    Code:
    <body>
    <script language="JavaScript">
    var abc=screen.width
    window.open('about:blank','window name','width=abc,height=200');
    </script>
    </body>
    its pretty the same

    again dont laugh at me, i know nothing about JS
    Well I have nothing to laugh to.. thats why I make tutorials

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97
    Nice tutorial! Thanks!

  5. #5
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6
    Thanks
    Sidewinder did my post help you?

  6. #6
    Programming God xtraze is an unknown quantity at this point
    Join Date
    Dec 2006
    Location
    Sri lanka
    Posts
    908
    Really great tutorial and I am sure I am going to use this, thank you for sharing it.

  7. #7
    TcM
    TcM is offline
    Code Warrior TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM is a name known to all TcM's Avatar
    Join Date
    Aug 2006
    Posts
    11,461
    Blog Entries
    6
    Quote Originally Posted by xtraze View Post
    Really great tutorial and I am sure I am going to use this, thank you for sharing it.
    Hope you use it Thats why I share code, because someone might need it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Screen resolution
    By NeedHelp in forum PHP Forum
    Replies: 6
    Last Post: 05-14-2007, 01:54 PM
  2. capture screen shot from an application during run time
    By engr in forum Visual Basic Programming
    Replies: 1
    Last Post: 01-29-2007, 03:38 PM
  3. 16 " screen
    By techni68 in forum Computer Hardware
    Replies: 5
    Last Post: 01-22-2007, 10:43 AM
  4. Capture the screen in a TImage
    By MrDiaz in forum Pascal/Delphi
    Replies: 3
    Last Post: 12-06-2006, 11:57 AM
  5. Change Resolution, Change Size
    By Void in forum C# Programming
    Replies: 1
    Last Post: 06-13-2006, 02:48 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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