Solved

Screen Size Detection versus inches ?

Posted on 1998-01-23
1
411 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
Comment Utility
<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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now