You need to know which browser you're dealing with to be able to do the right Javascript trick.
This is where the navigator
browser object comes in. This object holds all kinds of details about
the browser. Here are the relevant properties of this object:
Provides the name of the browser application.
Provides the version of the browser.
Provides more details about the browser.
For example, here's a script that displays these properties in a Web page.
note the + sign, which you use to join text strings together in java script:
Just save it as .HTML file and try to open in different browsers (whether IE or FF) and see the difference.
This is where the navigator
browser object comes in. This object holds all kinds of details about
the browser. Here are the relevant properties of this object:
- Code:
navigator.appName
Provides the name of the browser application.
- Code:
navigator.appVersion
Provides the version of the browser.
- Code:
navigator.userAgent
Provides more details about the browser.
For example, here's a script that displays these properties in a Web page.
note the + sign, which you use to join text strings together in java script:
- Code:
<html>
<head>
<title>
What's Your browser?
</title>
</head>
<body>
<script language="javascript">
document.write("You're using: " + navigator.appName)
document.write("<br><br>")
document.write("Version: " + navigator.appVersion)
document.write("<br><br>")
document.write("Browser details: " + navigator.userAgent)
</script>
<h1>What's your Browser?</h1>
</body>
</html>
Just save it as .HTML file and try to open in different browsers (whether IE or FF) and see the difference.