Detect Browser, Platform, and Touch Capability Using Javascript

Here’s a method of detecting which browser you’re using and whether you’re on a mobile or desktop platform: <script type=”text/javascript”>   <!–   var userAgent = navigator.userAgent || window.navigator.userAgent;   var nav = navigator || window.navigator;   var isDesktop = nav[‘platform’].match(/(Mac|Win|Linux)/) && !userAgent.match(/Android/);   if (isDesktop) {     alert(“You’re on a Desktop!”);   };   –> </script> Need …

MSSQL 2005 Dynamic PIVOT

Here’s a method of generating a dynamic pivot of a dataset. It first generates the columns as a string (“[ColumnHeader0],[ColumnHeader1],[ColumnHeader2], …” format), builds a dynamic SQL string and executes it using the PIVOT expression. From the code below, the @cols variable is generated by using the FOR XML PATH expression. …

iOS6 Removed Mouse Events in Safari/UIWebView? (Updated)

UPDATE 10-08-2012: Here’s a blog entry on how to determine if the device you’re on has touchevents enabled. Note that most Javascript libraries/frameworks should already have some sort of detection for this built in. My demo for using Cubiq.org’s SpinningWheel control stopped working on iOS6. The issue was that I …

Dynamically Load Javascript Files Using XHR

It probably won’t be often, but sometimes you may find yourself having the need to load Javascript dynamically using XHR.   To name a few use cases: Developing a plugin architecture for an HTML5 application. In order to extend your application’s functionality. Load certain Javascript depending the browser environment. A …

CSS3 Image Reflections

Kind of a cool effect. Here’s an example: To get the image reflect on the bottom, I used the following CSS: -webkit-box-reflect: below 5px -webkit-gradient( linear, left top, left bottom, from(transparent), color-stop(0.75, transparent), to(rgba(255,255,255,0.3)) ); Here’s some other options: Basic -webkit-box-reflect: below; Offset -webkit-box-reflect: below 5px; Masking with Gradient -webkit-box-reflect: …

NSURL Failed With Error NSURLErrorDomain “bad URL”

I got the following error when trying to connect to my web service using NSURL: Failed with error: Error Domain=NSURLErrorDomain Code=-1000 “bad URL” My URL was a GET request and so had several parameters in it. At first, I tried to URL encode the spaces manually using %20 (you’ll have to use …