Solved

Screen Size Detection versus inches ?

Posted on 1998-01-23
1
421 Views
Last Modified: 2010-05-18
Hello. I am a little confused here.
I have one left frame and one right frame (the main one)
I tried to use the screen size detection script but it doesn't work properly. I am working on a 17 inches monitor set at 1024 x 780. and a 15 inches set a 800 x 600.
the browser pulls out the same file menuN4_800.html.

here is the script : I use the detection on netcape 4 only in this script.

<SCRIPT>
                      // if can't detect let think it have at least:
                      var w=640
                      var mode="640"
                      //let's try for any netscape:
                           if((navigator.javaEnabled()==true)&&(navigator.appName.indexOf("Netscape")!=-1))
                      {w=java.awt.Toolkit.getDefaultToolkit().getScreenSize().width;}
                      </SCRIPT>

<SCRIPT LANGUAGE="javaScript1.2">
                      //for MIE4 and NN4 we can do it so:
                      w=screen.width
                      </SCRIPT>

<SCRIPT>
                      if(w>=1280) mode ='1280';
                      if(w>=1024) mode ='1024';
                      if(w>=800) mode = '800';  
                      </SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
          bName = navigator.appName;
     bVer = parseInt(navigator.appVersion);
             if      (bName == "Netscape" && bVer == 3) ver = "n3";
             else if (bName == "Netscape" && bVer == 4) ver = "n4";
             else if (bName == "Netscape" && bVer == 2) ver = "n2";
             else if (bName == "Microsoft Internet Explorer" && bVer >= 2) ver = "e3";
             if (ver == "n3") {
      document.write('<FRAMESET COLS="178,*" FRAMEBORDER="0" FRAMESPACING="0" BORDER="0">' +
                     '<FRAME SRC="menuN3_biz.html" NAME="left" SCROLLING="NO" >' +
                     '<FRAME SRC="main.html" NAME="main" SCROLLING="AUTO">' +
                     '</FRAMESET>');
            }
                                                                   if (ver == "n4") {
      document.write('<FRAMESET COLS="178,*" FRAMEBORDER="0" FRAMESPACING="0" BORDER="0" SCROLLING="NO"  >' +
                     '<FRAME SRC="menuN4_biz.html" NAME="left" SCROLLING="NO" >' +
                     '<FRAME SRC="mainN4_'+mode+'.html" NAME="main" SCROLLING="AUTO">' +
                     '</FRAMESET>');
            }
             if (ver == "n2") {
      document.write('<FRAMESET COLS="178,*" FRAMEBORDER="0" FRAMESPACING="0" BORDER="0">' +
                     '<FRAME SRC="menuN2.html" NAME="left">' +
                     '<FRAME SRC="main.html" NAME="main" SCROLLING="AUTO">' +
                     '</FRAMESET>');
}
                                                                         if (ver == "e3") {
             document.write('<FRAMESET COLS="178,*" FRAMEBORDER="0" FRAMESPACING="0" BORDER="0">' +
                            '<FRAME SRC="menuIE_biz.html" NAME="left">' +
                            '<FRAME SRC="mainIE.html" NAME="main" SCROLLING="AUTO">' +
                            '</FRAMESET>');
             }
     </SCRIPT>

Of course I have 2 different files :
menuN4_800.html and menuN4_1024.html


Thank you for your help
0
Comment
Question by:fana
1 Comment
 
LVL 10

Accepted Solution

by:
kollegov earned 50 total points
ID: 1277750
<SCRIPT>
if(w>=1280) mode ='1280';
if(w>=1024) mode ='1024';
if(w>=800) mode = '800';
</SCRIPT>

reason is wrong order in above sevtion of script,
if resolution 1024 it will satisfy both last checks
and last assignment will give you 800!
use following order:

<SCRIPT>
if(w>=800) mode = '800';
if(w>=1024) mode ='1024';
if(w>=1280) mode ='1280';
</SCRIPT>

in this case first two will be passed OK
and last one give you 1024 for w=1024.


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question