Slide 9
Slide 9 text
BROWSER SNIFFING VS. FEATURE SNIFFING
Browser sniffing
if (navigator.userAgent.indexOf(“WebKit") > 0 ) {
// Run custom code for WebKit
} else {
// Run code that’s supported in other
// browsers
}
Feature detection
if(window.addEventListener) {
// Browser supports "addEventListener"
window.addEventListener("load", myFunction, false);
} else if(window.attachEvent) {
// Browser supports "attachEvent"
window.attachEvent("onload", myFunction);
}