Search All Articles Submit your Website or Blog to A New Internet Library
Monday, April 20, 2009
Detecting IE6, IE7 and Google chrome in Javascript.
Some times we need to detect the browser used by end user in Javascript and wants to apply browser specific actions like styles javascript. As the way javascript and styles is interpreted is different in different browser.
In order to detect IE6 in javascript you can use the below code
<script>
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
if(IE6)
{
// Implement browser specific activities for IE6
}
</script>
In order to detect IE7 in javascript you can use the below code
<script type='text/javascript'>
if((document.all))
{
if((navigator.appVersion.indexOf("MSIE 7.")!=-1))
{
// Implement browser specific activities for IE7
}
}
</script>
In order to detect Google Chrome in javascript you can use the below code
<script type='text/javascript'>
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(is_chrome)
{
// Implement browser specific activities for Google Chrome
}
</script>
Subscribe to:
Post Comments (Atom)
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.


0 comments:
Post a Comment
Post your comments/questions/feedback for this Article.