在jquery mobile中获取当前页面URL

Adi*_*Adi 2 url jquery jquery-mobile

我想在jquery移动网站上获取当前页面网址.(我使用默认的ajax导航).

我目前的尝试是这个(绑定到pagecreate),但不能在注入DOM的任何页面上工作.

$( '[data-role=page]' ).live( 'pagecreate',function(){
  $('#site-toggle').attr('href',"http://" + location.host.replace('m.','') + window.location.pathname); 
});
Run Code Online (Sandbox Code Playgroud)

谁知道我错过了什么?

一个.

Ged*_*rox 10

这不是你要找的:

var currentUrl = $.mobile.activePage.data('url');
Run Code Online (Sandbox Code Playgroud)