how can i use this script...

Discussion in 'JavaScript' started by Mac Weng, Dec 13, 2005.

  1. #1
    <script type=text/javascript>

    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    var screen_width = null;
    var screen_height = null;
    var resolution = null;
    if (navigator.javaEnabled()) {
    var toolkit = java.awt.Toolkit.getDefaultToolkit();
    var screen_size = toolkit.getScreenSize();
    screen_width = screen_size.width;
    screen_height = screen_size.height;
    resolution = toolkit.getScreenResolution();
    }

    </script>

    <script type=text/javascript>

    if ((screen_width != null)
    && (screen_height != null)
    && (resolution != null)) {
    document.write('<center><h1>Monitor Details:</h1><br><hr><br>');
    document.write('Screen Width: '+screen_width+'<BR>');
    document.write('Screen Height: '+screen_height+'<BR>');
    document.write('Screen Resolution: '+resolution+'<BR>');
    document.write('</center>');
    }
    else {
    document.write('<center><P>');
    document.write('I am sorry but we could not determine the details of this screen.You might not have Java enabled in this browser.');
    document.write('</center>');
    }

    </script>


    helloo this is my second thread....i need help with this....how can i use in my web page....because it keep said that ('I am sorry but we could not determine the details of this screen.You might not have Java enabled in this browser.'); eventhough i think in my IE it has a java enable...please...
     
    Mac Weng, Dec 13, 2005 IP
  2. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It works fine in firefox with java plugin but not in IE. You can use a hidden java applet to perform the same task (grabbing these values from applet through javascript).
     
    Cybernaut, Dec 20, 2005 IP
  3. Mac Weng

    Mac Weng Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3

    emmm....so how can i do that ??? please teach me...
     
    Mac Weng, Dec 20, 2005 IP
  4. Cybernaut

    Cybernaut Peon

    Messages:
    408
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Make a java applet with public methods to get these values:

    import java.awt.*;
    import java.applet.*;
    
    public class MyApplet extends Applet {
    
        public MyApplet(){
        }
    
        public Dimension getScreenSize(){
            return Toolkit.getDefaultToolkit().getScreenSize();
        }
    
        public int getScreenResolution(){
            return Toolkit.getDefaultToolkit().getScreenResolution();
        }
    
    }
    Code (markup):
    Compile the applet and insert it in the document using Applet tag:

    <APPLET id="myApplet" name="myApplet" width="1" height="1" code="MyApplet.class" codebase="." [B]MAYSCRIPT[/B]></APPLET>
    Code (markup):
    Dont forget the MAYSCRIPT attribute. Now get the values as:

    <script type=text/javascript>
    
    var screen_width = null;
    var screen_height = null;
    var resolution = null;
    if (navigator.javaEnabled()) {
        var screen_size = document.getElementById("myApplet").getScreenSize();
        screen_width = screen_size.width;
        screen_height = screen_size.height;
        resolution = document.getElementById("myApplet").getScreenResolution();
    }
    
    </script>
    Code (markup):
    Thats it. :)
     
    Cybernaut, Dec 21, 2005 IP
  5. Mac Weng

    Mac Weng Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    what do u mean with this cybernaut???
     
    Mac Weng, Jan 4, 2006 IP