Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Javascript - If and browser detect?
Hi people, I was wondering if you could help me with some javascript.
I am looking for the browser detect function and a basic layout of an if statment.
What Im looking for the code to do is
if the browser is firefox or oprea then
display an image
if not then end the if statment
Thanks guys
6 Answers
- Mark aka jack573Lv 71 decade agoFavorite Answer
One place on the web for the browser detect function in javascript is
http://www.quirksmode.org/js/detect.html
also
http://www.webreference.com/tools/browser/javascri...
and
http://www.developerfusion.co.uk/show/2186/
These basically all give you the skeleton code of how to find which browser is what. You need to edit/change the code so it can do what you want, like display the image.
There are links to stuff here, http://www.actionext.com/detect.shtml
An if statement in javascript would be
if (condition) {
// if the condition is true, like browser == "firefox"
// show the image
}
- 1 decade ago
basic layout of an if statement is,
if (condition=true) {do this}
Alternatively learning JavaScript is a start http://www.w3schools.com/js/default.asp
I haven't updated my last browser detect script in a long time. The JavaScript navigator object isn't very accurate, in my script I match certain JavaScript features the browser supports and use that to match the browser accurately.
- 1 decade ago
<html>
<body>
<script type="text/javascript">
var browser=navigator.appName
if ((browser = opera) || (brower = firefox)){
document.write("<img src="imageurl">)
}
</script>
</body>
</html>
- 1 decade ago
you have to use user agent header to identify the browser
visit the following link
- How do you think about the answers? You can sign in to vote the answer.
- 1 decade ago
Try asking at Help board website they might be able to help you out
------------------------------------
GET YOUR QUESTION ANSWERD AT