HTML and CSS Reference
In-Depth Information
You should also be aware of how Web Sockets usage scales in terms of server resources.
Traditional web requests only take up dedicated resources from the server for a split
second at a time, which means you can serve a lot of web traffic from your server without
having too much overlap and thus running out of resources.
Sockets, on the other hand, tend to be more dedicated, so there can be issues with
resource availability under high load. Your server setup and architecture will vary
greatly with your application's needs and are a big factor in how well you are able to
utilize Web Sockets.
See Also
For more information about Socket.io, see the project home page at http://socket.io .
10.6 History
Problem
For your web application, you want fine-grained control to manage the forward/back-
ward button history queue, as well as the displayed URL in the address bar of the
browser.
Solution
HTML5 brings us several important enhancements to the browser's window.history
object, commonly referred to as the History API.
To test if the browser supports the enhanced History API, use the following feature-
detect:
var history_support = !!(window.history && window.history.pushState);
Normally, when you change the URL in the address bar, the browser initiates a new
request to the server for that new page. But today's complex web applications more
commonly use Ajax to load only new information, without full-page refreshes. This
leads to a disconnect, where web applications can't update the address bar URL because
they don't want a browser page refresh.
To change the URL in the address bar without forcing a new page load, use the his
tory.pushState(...) method. This method updates the URL in the address bar and
creates a special state-oriented entry in the browser's history. This means that if a user
then clicks the back button in her browser, instead of doing a reload of the previous
page, the browser fires the new popstate event, which your application can respond to
by setting the page back to that previous state.
 
Search WWH ::




Custom Search