Solved

Screen Size Detection versus inches ?

Posted on 1998-01-23
1
429 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

738 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