HTML
  Home arrow HTML arrow Page 3 - Finishing Touches for a Common Browser Men...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Finishing Touches for a Common Browser Menu
By: Chrysanthus Forcha
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating:  stars stars stars stars stars / 0
    2009-05-08

    Table of Contents:
  • Finishing Touches for a Common Browser Menu
  • Modifying the code
  • Making the code work with other browsers
  • The nuance explained
  • Advantages and disadvantages of this simple layout

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finishing Touches for a Common Browser Menu - Making the code work with other browsers


    (Page 3 of 5 )

    The non-image and image code (the first two codes you have downloaded) work with Internet Explorer, Netscape and Mozilla Firefox without any problems. I have shown you above how you can change the code to work with Opera or Safari. The problem now is that if you change the code to work with some other browser, it may not work again with any or all of the three original browsers for which we wrote it.

    To allow the code work with the three browsers, and then make the same code work with some other browsers of your choice, do the following: for each statement that you have to change, you should put the particular statement for the particular browser in an “if else-if else-if…” statement as follows:


    if (Opera)

    {

    //statements for Opera are used here

    }

    else if (Safari)

    {

    //statements for Safari are used here

    }

    else if (some other Browser)

    {

    //statements for some other browser are used here

    }

    -

    etc.

    -

    else

    {

    // the default original statements for Internet Explorer, Mozilla Firefox,

    // and Netscape is used here

    }



    You do this for any of our statements that do not work with a particular browser. The "if" or "else-if" condition test is for the browser the user is using. I will show you how to do that now. You can also test for the version, but I will not show you how to test for the version in this series. The above statement changes as follows (with a nuance):


    if (navigator.appName == "Microsoft Internet Explorer")

    {

    //statements for Microsoft Internet Explorer are used here

    }

    else if (navigator.appName == "Opera")

    {

    //statements for Opera are used here

    }

    else if (navigator.appName == "Netscape")

    {

    //statements for that Netscape are used here

    }

    else

    {

    // alert that the code may not work well with your browser.

    //put the statements that works for Internet Explorer, Mozilla Firefox and

    //Netscape here

    }


    JavaScript has an object called the navigator object. This object has a property called appName. This property with the navigator object returns the name of the user’s browser. Our statement here is not the same as the statement above. There is a nuance, which you will see as I will explain in the next section.

    More HTML Articles
    More By Chrysanthus Forcha


     

    HTML ARTICLES

    - Hello HTML 5, Goodbye Gears
    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek