How to change pages in a web application in the age of HTML5

More and more web sites stop to use the old way of request-response page switches, where each page switch refreshes the entire page in the browser. Instead they refresh just the data and the page itself is not reloaded. This way has better for performance and it also makes a much smoother user experience. You can see a great example in github where you click on one of the files. In this post I am going to explain how this is achieved step by step. My Demo Requirements: For some reason, almost all of the examples I saw on the internet about this used jquery in one way or another. This post is NOT using any third-party libraries except for history.js script for browsers which do not support the history.pushState feature. I took this script from github. Step 1 – handle links We want that pressing a link will trigger a JavaScript function. You can do that in many ways. I have done it like this: It will go over all the links in the page and will attach a call to function goto(), but it will do it just for the links which points to inner pages. The goto() Continue reading How to change pages in a web application in the age of HTML5

4 JavaScript trivia questions that may help you understand the language a bit better

The next 4 Javascript questions may seem easy to some of you, but I am sure that more than a few will get confused. I believe that these 4 simple questions will help you understand a key feature of the language. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: Nothing, because outer() returned a function but it wasn’t executed. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: alert ‘>2’, because the x that inner() uses is the same x the outer() uses. Question: What will happen after executing the next JS code? 1. Nothing 2. alert ‘>undefined’ 3. alert ‘>1’ 4. alert ‘>2’ Answer: alert ‘>undefined’. Inner uses a variable x which is different than the outer x. The inner x is never initialized Question: What will happen after executing the next JS code? By now the answer should be obvious: alert ‘>3’ .

Which client will dominate?

I first got into the magical world of the internet in the happy 90’s. Back then you could find 3 basic types of network application clients: Internet lightweight web sites (HTML, JS), installed applications with network connection like ICQ or Applets. The years went by, the internet connection got faster and richer applications came out of the desktop and into the browser. The web applications clients became fatter. Even if the desktop applications still exist, they have clearly become a lot less common. That was about the time I started developing in java. The obvious solution for many of these fat clients were the java web frameworks like Struts, JSF and all the others. But as the years went by a new approach became more and more popular – the Ajax web applications, with GMail in the lead. Fat clients never looked better and the usability was excellent. It is almost as if we are using desktop applications (!?!). JavaScript was never so cool. Libraries like JQuery are born every day as well as some new solutions like GWT to make our life with JavaScript easier. But the story doesn’t end here. With the birth of the smart cellphones an Continue reading Which client will dominate?