Javascript Browser sniffing?

  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Hey, although I hate browser sniffing, I think I'm gonna need some, because of IE's lame position rendering

Now I know about document.all() to separate out IE, but that also targets Opera as well. Does anyone know of a browser-sniffing technique that will target ONLY IE and nothing else? Even if its a combination of techniques.

Thanks guys.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

RTM:
I'm not positive, but I think this link my help. The thread i started was called Browser Verification Javascript :D You say tomato I say tomoto.
http://www.ozzu.com/ftopic23182.html&highlight=browser+verification
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

:roll: yes um, um I um ooops :oops:

I have actually thought of a way of getting around my problem using a CSS browser-sniffing hack I know so it should all be sorted (shouldn't say that before testing though :lol: )

thanks for the link though :D
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

PHP has an extension for the browscap.ini. Go check out http://www.GaryKeith.com for information. I know all about implementing it for ASP on IIS, but nothing about the PHP version. This is about the only site, these days, that continues to work on keeping this file updated, not even MS (it's inventor) bothers, probably because it was actually a good idea.

Basically, with this, the idea is to only send stuff to the browser than the browser actually understands. You can create multiple, browser-specific, JS and CSS files and with this system, dynamically send them out based on whether a user-agent will know what to do with them. Obviously, this can be as complicated or simple as you're interested in making it...

.c
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Carnix wrote:
You can create multiple, browser-specific, JS and CSS files


That is more than enough to put me off, TBH. I'm not interested in going down that road - browser-specific code is a bad thing, the only reason I am using it for this application is to create super-efficient code. In actual fact I did some testing now and it seems that I need to group opera with IE anyway, cos it's not got a very good rendering engine :roll: ho hum....
  • _nYght
  • Novice
  • Novice
  • _nYght
  • Posts: 17

Post 3+ Months Ago

maybe you have solve your problem but if not here's one trick
Code: [ Select ]
function msieversion()
// return Microsoft Internet Explorer (major) version number, or 0 for others.
// This function works by finding the "MSIE " string and extracting the version number
// following the space, up to the decimal point for the minor version, which is ignored.
{
  var ua = window.navigator.userAgent
  var msie = ua.indexOf ( "MSIE " )
  if ( msie > 0 )    // is Microsoft Internet Explorer; return version number
    return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
  else
    return 0  // is other browser
}
  1. function msieversion()
  2. // return Microsoft Internet Explorer (major) version number, or 0 for others.
  3. // This function works by finding the "MSIE " string and extracting the version number
  4. // following the space, up to the decimal point for the minor version, which is ignored.
  5. {
  6.   var ua = window.navigator.userAgent
  7.   var msie = ua.indexOf ( "MSIE " )
  8.   if ( msie > 0 )    // is Microsoft Internet Explorer; return version number
  9.     return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
  10.   else
  11.     return 0  // is other browser
  12. }



and this

Code: [ Select ]
if ( msieversion() >= 4 )
  document.alert( "This is IE4 or later - safe to use all IE4 features" )
else if ( msieversion() >= 3 )
  document.alert( "This is IE3 - safe to use ActiveX" )
else
  document.alert( "This is not IE" )
  1. if ( msieversion() >= 4 )
  2.   document.alert( "This is IE4 or later - safe to use all IE4 features" )
  3. else if ( msieversion() >= 3 )
  4.   document.alert( "This is IE3 - safe to use ActiveX" )
  5. else
  6.   document.alert( "This is not IE" )

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 182 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.