Skip to main content


jQuery Mobile data-title behavior with multi-page template

The jQuery Mobile library comes with wonderful Ajax page transition capabilities. But you have to keep a look on the Page title as you navigate between the various pages and I have tried to document the behavior under different scenarios in this blog. Consider the below code, click the below link to launch the code in a separate window. Launch <!DOCTYPE html> <html>   <head>     <title>Main Page</title>     <meta name="viewport" content="width=device-width, initial-scale=1">     <link rel="stylesheet" href="" />      <script src=""></script>     <script src=""></script>   </head>   <body>     <div id="page1" data-role="page" data-title="p

autofocus to multiple controls in HTML5

The HTML5  spec says: There must not be more than one element in the document with the  autofocus  attribute specified. Excellent, so what happens if you set multiple elements with the autofocus attribute? And in various browsers? Results below ... Autofocus not supported: IE9  First Element gets the focus: IE 10 preview, FF The last element gets the focus: Chrome, Opera, Safari Though its up to the User Agents to implement the behavior, I prefer the Webkit implementation of this feature compared to that of Mozilla and Trident.  Why?  HTML5 says that browsers should gracefully degrade. They should try to render whatever possible. Not being strict that is. So if a browser stops with the first autofocus, one will never know if there were more than one autofocus elements in the document. But, if the browser renders and sets every autofocus as it parses the document, thus stopping at the last autofocus, the developer will immediately know something is a

Patent for a single shared profile service

I have faced this problem multiple times. And its damn frustrating. Yes, I'm talking about the ten different places my profile is or was on the web. Google, Google apps account, LinkedIn, Twitter, FB and heaven knows where else. Any change in status or the way I want my profile to be worded, I have to remember and go and update all these places. Its a pain in all the wrong places. Trust me. Then I thought, someone must be providing such a shared profile service. You update your profile just one place and then push it to all these various social networks and web sites. I searched. Found nothing. I searched hard, asked my friends about this. Nothing! Zilch!! There were a few websites, that were almost there, but not exactly what I wanted. Gravatar has this for one's avatar. So why not something for profiles? Nopes. Then I had an enlightenment! Why not build this service and provide to the users on the web. I had an even better idea, why not patent it. Provide such a wonde

Developing for Android: HTML5 and Qt

Recently read a post by my friend and ex-collegue Sai Geetha on her very famous Android blog . I am now reading her blog to start learning a bit about Android development. In her most recent post, she has listed 4 ways for developing in Android. 1. Using the Software Development Kit (SDK) with Java 2. Native Development Kit using C / C ++. 3. RenderScript using C99 - used to write faster graphics code like the Google Books page turn animation etc. 4. Android Scripting Layer using Python etc. Just thought I'll extend the above further and add a couple of thoughts to this list... The trend now and what is gaining a lot of traction is developing cross platform apps. So you develop once and can deploy it on multiple platforms. Java showed this promise earlier, but is slowly making way for the newer and greater things out there. One should see how the recently released Java7 will perform. And Java is still the greatest thing for Android development today. Java is also the reco

Pageviews: FF vs Chrome vs IE is a new blog and so the page visits are gradually picking up. Recently crossed a 1000 page views and Google stats throws up a nice picture on how the platform and browser split amongst the audience is.   Overall the ratio generally follows the current market trends. I've been following the trend regularly on my site and not surprising to see how Chrome is raising almost every week.

Solutions: Object Oriented JavaScript: 3. Functions

Previous: Chapter 2: Primitives Chapter 3: Functions 1. Write a function that converts a hexadecimal color, for example blue "#0000FF", into its RGB representation "rgb(0,0,255)". Name your function getRGB() and this it with this code:   var a = getRGB("#00FF00");   a;          rgb(0,255,0)   //Simple logic for getRgb()     var getRGB = function f(hexColor) {     var result = "rgb(";        result += parseInt("0x"+hexColor[1]+hexColor[2]) + ", ";     result += parseInt("0x"+hexColor[3]+hexColor[4]) + ", ";     result += parseInt("0x"+hexColor[5]+hexColor[6]) + ")";     return result;   }       >> getRGB("#0000FF");   "rgb(0, 0, 255)"   >> getRGB("#00FF00");   "rgb(0, 255, 0)" 2. What does each of these lines print in the console?     >> parseInt(1e1)     10    //1e1 is evaluated first     >> parseInt('1e1'

Solutions: Object Oriented JavaScript: Chapter 2: Primitives

JavaScript experts can skip this.   While reading the book, Object Oriented JavaScript by Stoyan Stefanov , I thought it would be a good idea to just solve the exercises presented in the book and store the solutions away. Takes me back to my school days when I was serious about learning stuff :) This will be a multi-part blog, with each blog entry solving exercises presented in one chapter of the book. The entire set of solutions will be eventually made available in my JavaScript site. So here goes ...   Chapter 2: Primitive Data Types, Arrays, Loops and Conditions   1. What is the result of executing each of these lines in the console? Why? >> var a; typeof a; undefined  // a has not been defined with any value >> var s = '1s'; s++; NaN  // converting 1s to a number is ambiguous with addition   >> !!"false" true  // "false" is a valid string   >> !!undefined false  //undefined is a falsy   >> typeof -Infinity "