Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:23:08+00:00 2026-06-13T05:23:08+00:00

Pls look at the following code: html… <pre id=’output’></pre> html… JS function log(text) {

  • 0

Pls look at the following code:
html…

 <pre id='output'></pre>

html…

JS

 function log(text) {
    var div = document.getElementById('output');
    div.innerHTML += text + '\n';
 }

function foo() {

    var browser=0;
    if(navigator.appName.toUpperCase()=="MICROSOFT INTERNET EXPLORER")
        browser=1;
    else
    if(navigator.appName.toUpperCase()=="NETSCAPE")
        browser=2;
    log ('browser:'+browser);
    if (browser==1)
    {
        log ('IE');
    }
    if (browser==2);
    {
        log ('Chrome');
    }

    if (browser==0);
    {
            log ('Could not determine broweser type');
            return;
    }
  }

When I run this from IE the output is:
browser:1 ie not supported Chrome extension will be loaded Could not determine broweser type

When I run it from Chrome the output is:
browser:2
Chrome extension will be loaded
Could not determine broweser type


How can it be that browser has more than one value?
10xs,
Nir

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:23:10+00:00Added an answer on June 13, 2026 at 5:23 am

    You have a very beginners mistake in your code

    The ; at the end of the if
    if (browser==0); causes your if condition to end and the rest is a normal code block which gets executed every time no matter the value of browser

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pls look at following code <select name=VideoType id=VideoType style=width:60px> <option value=All>All</option> <option value=Movie>Movie</option> <option
pls look at following piece of code. for (int j = 0; j <
Pls check code .html form gets submitted even if javascript returns false. <form id=form1
Could any of you pls explain the following code. For eg., Why D,d is
Pls look at the below code. when i run my application using Run with
Hi am having a annoying issue.Look at the following code, In the code I
window.onload = raknaUtMedelvarde; function raknaUtMedelvarde(){ var tabell = document.getElementById(temperaturtabell); var rader = tabell.getElementsByTagName(tr); for
when i'm looking at the html source, i look this javascript code <script src=http://connect.facebook.net/en_US/all.js#xfbml=1></script>
How to persentmodalview with transparent background, pls reference the following snapshot: How to persent
This code shows syntax error in the parameter declaration.. Pls help me to solve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.