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.
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
.
Create
main.html
with an emptydiv
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>
Add the following script to the
<head>
section to fetch the URL of the anchor button when it is clicked:$("#main").live("pageinit", function(event) { dispPath($.mobile.getDocumentUrl()); $("a").bind("click", function(event, ui) { dispPath($(this).attr("href")); event.preventDefault...