Friday, February 27, 2015

Built in Apache server in Mac OS X

Mac OS X has built-in Apache Web server which can be very useful to quickly test web app.

The Apache configuration file is:
/etc/apache2/httpd.conf
Listen 80
DocumentRoot "/Library/WebServer/Documents"
ErrorLog "/private/var/log/apache2/error_log"

Commands to start/stop Apache server
sudo apachectl start
sudo apachectl stop
sudo apachectl restart

Copy some website for testing
sudo cp -r example-multipage-shim-master/www-built/ /Library/WebServer/Documents/test

Then access testing page using localhost and port 80
http://localhost/test/page1.html


Wednesday, February 18, 2015

IE user agent

"Windows NT 6.2" indicates the browser is on a computer running Windows 8, whereas "Windows NT 6.1" indicates the computer is running Windows 7.

32-bit Internet Explorer 10 on 32-bit Windows 8:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)

32-bit Internet Explorer 10 on 64-bit Windows 8:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)

64-bit Internet Explorer 10 on 64-bit Windows 8:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)

Internet Explorer 10 on Windows RT:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0)

If this token is present at the end of the UA string, the computer has touch capability, and is running Windows 8 (or later)
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; Touch)

In Javascript, we use below to detect it is 64-bit IE on 64-bit windows. It should be an acceptable solution.
navigator.userAgent.indexOf("Win64") != -1 && navigator.userAgent.indexOf("x64") != -1

Btw, IE11 doesn't use MSIE anymore, we need look for Trident/7.0 rv11 from user agent. With regarding to complicate user agent string detect logic, it might be better to detect using browser supported features.