O'Reilly logo

jQuery Mobile Cookbook by Chetan K Jain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing an URL

The $.mobile.path object provides properties and methods that you can use to work with URLs. This recipe shows you how to fetch the components of a URL using the $.mobile.path.parseUrl() method.

Getting ready

Copy the full code of this recipe from the code/09/parseurl source folder. You can launch this code by using the URL: http://localhost:8080/09/parseurl/main.html.

How to do it...

  1. Create main.html with an empty div tag and an anchor link, as shown in the following code snippet:
    <div data-role="content">
      <div id="msgdiv"></div>
      <a href="http://user:pwd@localhost:8080/09/main.html?img=img1.png#imgview"
        data-role="button">Link 1</a>
    </div>
  2. Add the following script to the <head> section to fetch the URL of the anchor button when it is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required