04.11.2015 Views

javascript

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9: Client Detection<br />

(continued)<br />

};<br />

var browser = {<br />

//browsers<br />

ie: 0,<br />

firefox: 0,<br />

safari: 0,<br />

konq: 0,<br />

opera: 0,<br />

chrome: 0,<br />

safari: 0,<br />

};<br />

//specific version<br />

ver: null<br />

var system = {<br />

win: false,<br />

mac: false,<br />

x11: false,<br />

};<br />

//mobile devices<br />

iphone: false,<br />

ipod: false,<br />

nokiaN: false,<br />

winMobile: false,<br />

macMobile: false<br />

}();<br />

//detection of rendering engines/platforms/devices here<br />

return {<br />

engine: engine,<br />

browser: browser,<br />

system: system<br />

};<br />

Next, simple detection for the strings ” iPhone ” and ” iPod ” is used as follows to set the values of the<br />

related properties accordingly:<br />

system.iphone = ua.indexOf(“iPhone”) > -1;<br />

system.ipod = ua.indexOf(“iPod”) > -1;<br />

system.macMobile = (system.iphone || system.ipod);<br />

Nokia Nseries mobile phones also use WebKit. The user - agent string is very similar to other<br />

WebKit - based phones, such as the following:<br />

Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95/11.0.026; Profile MIDP-2.0<br />

Configuration/CLDC-1.1) AppleWebKit/413 (KHTML, like Gecko) Safari/413<br />

252

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!