jQuery Address Docs
The jQuery Address plugin doesn't add deep linking support automatically but provides the simplest possible API that developers can use to implement it on their own.
The most important concept of the plugin is that any navigation functionality should be invoked only when a change event is dispatched. This ensures that the proper code will be executed each time when the user clicks on the page, uses the back button of the browser or enters the site through a deep link.
Sample usage
A basic implementation in pure JavaScript can look like this:
The plugin also provides a jQuery function which can be directly used in the following way:
The above snippet can be extended with an additional function that processes the link value:
By default the plugin automatically adds the appropriate JavaScript event handler to every link that has a rel attribute in the following format:
Supported browsers
- Internet Explorer 6.0+
- Mozilla Firefox 1.0+
- Safari 1.3+
- Opera 9.5+
- Chrome 1.0+
- Camino 1.0+
API reference
The jQuery Address plugin does not require initialization. Some of it's properties can be configured with query parameters using the following format: jquery.address-1.0.js?history=1&tracker=pageTracker._trackPageview&strict=0
Events
| $.address.change(fn) | Returns: jQuery Address |
| Binds a function to be executed whenever the address is changed. The function receives a single event object parameter that contains the following properties: value, path, pathNames, parameterNames, parameters and queryString. | |
| $.address.init(fn) | Returns: jQuery Address |
| Binds a function to be executed once when the address is initiated. The function receives a single event object parameter that contains the following properties: value, path, pathNames, parameterNames, parameters and queryString. | |
| $.address.internalChange(fn) | Returns: jQuery Address |
| Binds a function to be executed when the address is changed from inside the page that uses the plugin. The function receives a single event object parameter that contains the following properties: value, path, pathNames, parameterNames, parameters and queryString. | |
| $.address.externalChange(fn) | Returns: jQuery Address |
| Binds a function to be executed when the address is changed from the browser usually when entering the page or using the back and forward buttons. The function receives a single event object parameter that contains the following properties: value, path, pathNames, parameterNames, parameters and queryString. | |
Methods
| $.address.baseURL() | Returns: String |
| Provides the base address of the document. | |
| $.address.history() | Returns: Boolean |
| Provides the state of the history mode setting. | |
| $.address.history(value) | Returns: jQuery Address |
| Enables or disables the history mode. Currently unsupported in Webkit browsers. | |
| $.address.parameter(name) | Returns: String |
| Provides the value of a specific query parameter. | |
| $.address.parameterNames() | Returns: Array |
| Provides a list of all the query parameter names. | |
| $.address.path() | Returns: String |
| Provides the deep linking value without the query string. | |
| $.address.pathNames() | Returns: Array |
| Provides a list of all the folders in the deep linking path. | |
| $.address.queryString() | Returns: String |
| Provides the query string part of the deep linking value. | |
| $.address.strict() | Returns: Boolean |
| Provides the state of the strict mode setting. | |
| $.address.strict(value) | Returns: jQuery Address |
| Enables or disables the strict mode. | |
| $.address.title() | Returns: String |
| Provides the title of the HTML document. | |
| $.address.title(value) | Returns: jQuery Address |
| Sets the title of the HTML document. | |
| $.address.tracker() | Returns: String |
| Provides the currently set page view tracking function. | |
| $.address.tracker(value) | Returns: jQuery Address |
| Sets a function for page view tracking. By default both 'urchinTracker' and 'pageTracker._trackPageview' are automatically invoked if they exist in the page. | |
| $.address.value() | Returns: String |
| Provides the current deep linking value. | |
| $.address.value(value) | Returns: jQuery Address |
| Sets the current deep linking value. | |
Functions
| address(fn) | Returns: jQuery |
| Adds the plugin functionality to a DOM element and disables the default click behavior. Accepts an optional function parameter that allows custom processing of the deep link value. | |