Posts

Showing posts with the label Sniff

On User Agent Sniffing

Oh well, who was following me on twitter today is already bored about this topic (I guess) but probably other developers would like to read this too so ... What Is UA Sniffing UserAgent sniffing means that a generic software is relying into a generic string representation of the underlying system. The User Agent is basically considered a unique identifier of " the current software or hardware that is running the app ". In native applications world UA could be simply the platform name ... where if it's " Darwin " it means we are in a Mac platform, while if it's Win32 or any other " /^Win.*$/ " environment, the app reacts, compile, execute, as if it is in a Windows machine ... and so on with Linux and relative distributions. The "Native" Software Behavior If you have an hybrid solution, example those solutions not allowed anymore but called Hachintosh not long time ago, your machine has most likely Windows Starter capable Hardware but it...

Opera Detection Revamped?

I am surfing in a nightmare of problems with IE and Opera right now ... all these problems come from sessionStorage implementation ... I am almost there, but right now just think about this question: How to know if onload and unload event are supported without firing them? Apparently, it has never been that simple! Object.prototype.toString .call(window.opera) === "[object Opera]" ; Enjoy P.S. Prototype Framework uses this trick since version 8, I had no idea about that! Good one!

32 bytes, ehr ... 9, ehr ... 7!!! to know if your browser is IE

Update another clever trick from comments, which I will explain later: if(!+"\v1") // true only in IE if("\v"=="v")// true only in IE try{IE=window=!1}catch(e){IE=!0} it works, doesn't it? The reason is simple, if we consider "\v" as a vertical space, browsers interpreter that check in this way: !(+ 1 ) where "not one" is always false, considering that 0 is always casted as false, and every other number is casted as true. Internet Explorer will ignore the vertical space, trying to cast a "v" character into a number, thanks to the sign (plus or minus, it does not matter) // How IE interpreters the code !(+"v") // where isNaN(+"v") === true // and where NaN is implicitly casted as false About conditional comments I read a lot of comments in both Ajaxian and other places ... well, guys, this is a trick as conditional comment is. The day IE will interpret correctly the "\v" character, Opera or so...