Jump to content

Javascript + browsers question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
psychological

psychological

    Newbie

  • Members
  • Pip
  • 1 posts
Hey everyone, im beginning to learn javascript/c++ and programming in general, however I was trying to wrap my head around javascript today. I was wondering if anyone could explain to me how JavaScript can be used to display things differently in two different browsers?

Thanks for any help, helping me to understand this!

#2
v0id

v0id

    Retired

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,936 posts
You determine which browser the user are running, and then you show something for the user if he uses a specific browser. There's tons of material on the net about determining browsers.

#3
csmith1991

csmith1991

    Newbie

  • Members
  • Pip
  • 6 posts
Somthing like this allows you to detect the browser that is being used and display unique content depending on the browser.

<script>

var BrowserName = navigator.appName
if (BrowserName == "Netscape")
{
alert("Your using Netscape");
}
else
{
if (browserName == "Microsoft Internet Explorer")
{
alert("Your using IE");
}
else
{
alert("What ARE you browsing with here?");
}
}

</script>