Skip to content

Commit b416141

Browse files
committed
Fix history functions when viewing an application in an iframe - see issue 560 for details
1 parent 6121920 commit b416141

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

js/jquery.mobile.dialog.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,17 @@ $.widget( "mobile.dialog", $.mobile.widget, {
5555

5656
//close method goes back in history
5757
close: function(){
58-
window.history.back();
58+
//get the #url of the previous page in history, or the first page if there is no previous
59+
var url = $.mobile.urlHistory.getPrev().url;
60+
if (url === null || url == "") url = $.mobile.firstPage.attr("data-url");
61+
url = "#" + url;
62+
63+
//get the transition last used, or default to "pop"
64+
var transition = $.mobile.urlHistory.getActive().transition || "pop";
65+
66+
// change the page using the reverse transition
67+
$.mobile.changePage(url, transition , true, true, true);
68+
return false;
5969
}
6070
});
6171
})( jQuery );

js/jquery.mobile.navigation.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,17 @@
710710

711711
//if there's a data-rel=back attr, go back in history
712712
if( $this.is( ":jqmData(rel='back')" ) ){
713-
window.history.back();
713+
714+
//get the #url of the previous page in history, or the first page if there is no previous
715+
var url = $.mobile.urlHistory.getPrev().url;
716+
if (url === null || url == "") url = $.mobile.firstPage.attr("data-url");
717+
url = "#" + url;
718+
719+
//get the transition last used, or use default
720+
var transition = $.mobile.urlHistory.getActive().transition || "slide";
721+
722+
// change the page using the reverse transition
723+
$.mobile.changePage(url, transition , true, true, true);
714724
return false;
715725
}
716726

0 commit comments

Comments
 (0)