Skip to Main Content
Pro JavaScript for Web Apps
book

Pro JavaScript for Web Apps

by Adam Freeman
June 2012
Intermediate to advanced content levelIntermediate to advanced
278 pages
7h 37m
English
Apress
Content preview from Pro JavaScript for Web Apps

C H A P T E R  4

Using URL Routing

In this chapter, I will show you how to add another server-side concept to your web app: URL routing. The idea behind URL routing is very simple: we associate JavaScript functions with internal URLs. An internal URL is one that is relative to the current document and contains a hash fragment. In fact, they are usually expressed as just the hash fragment on its own, such as #summary.

Under normal circumstances, when the user clicks a link that points to an internal URL, the browser will see whether there is an element in the document that has an id attribute value that matches the fragment and, if there is, scroll to make that element visible.

When we use URL routing, we respond to these navigation changes by ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro JavaScript Development: Coding, Capabilities, and Tooling

Pro JavaScript Development: Coding, Capabilities, and Tooling

Den Odell
JavaScript: Best Practice

JavaScript: Best Practice

James Kolce, Moritz Kroger, Ivan Curic, Samier Saeed, Jeff Mott, M. David Green, Craig Buckler

Publisher Resources

ISBN: 9781430244615Purchase book