Solved

Screen Size Detection versus inches ?

Posted on 1998-01-23
1
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

705 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