The latest invention from the Web 2.0 world - Hyperlink 2.0. Some days ago, I saw a post on The Daily WTF on this topic. It was a noble attempt - but did not quite hit the target. So I decided to have a go at it myself.
This script is sooo Web 2.0(it is so Web 2.0 that I think that it is really Web 2.5). It works perfectly if there is no javascript(Graceful degradation). As a matter of fact, it works better if there is no javascript. Can you think of another Ajax app that works better if there no javascript? I can't think of one - this script is the first in that area.
Working
When a user clicks on a link, this script finds which page linked and then load that page using AJAX internally. Then it takes the contents of the <body> tag and replace the contents of the body tag of the current page with the new content. Thus we render the new page - without changing the URL.
For example, the page 'index.html' has a link to a page called 'next_page.html'. When the users clicks on this link, our script will use ajax to load the 'next_page.html' file internally - while showing a loading message to the user. Once the loading is complete, the script will extract the data inside the <body> tag of the 'next_page.html' page. Then it replaces the contents of the body tag of the current page with the new one.
Code
See the code for hyperlink 2.0(JS File).
This script uses the JX Ajax Library and the getElementsByClassName function.
Problems
Just in case that there is anything wrong with your sarcasm detectors, let me make myself very clear. Do not use this method. I just provided this sample to make fun of the overuse/abuse of ajax we are seeing on the web. The main reasons why you should not use this script are given below...- Slower than the traditional way
- No feedback - loading bars unavailable.
- Breaks the Back button.
- Users have no clue on which page they actually are - so they won't be able to bookmark the page.
- Users will think that nothing is happening - when they click on the link and nothing happens.
- And More...
0 Comments:
Post a Comment