jquery/jquery-mobile — Issue #3630: iOS 4.x history.back Bug
Author: brianantonelli
Created: 2012-02-23 21:42:27+00:00
State: open

We uncovered a bug in iOS 4 when running inside of a Phonegap container and calling history.back(). The problem is that history.back sends an encoded URL to $.mobile.changePage which makes JQM think that the page has not already been loaded and causes the file to be loaded again. This results in the same page being loaded into the DOM twice resulting in two copies of the page. The only difference being the data-url attribute one which is unencoded and the other which is encoded. Calling decodeURIComponent inside of $.mobile.loadPage seems to resolve this issue:

```javascript
page = settings.pageContainer.children( ":jqmData(url='" + decodeURIComponent(dataUrl) + "')" );
```

Without this change if I click a link that goes to page2.html, then click a link from page2.html to page3.html and then execute history.back() I get two copies of page2.html:

1. data-url="/Users/bantonelli/Library/Application Support/iPhone Simulator/4.3.2/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/ATC QA.app/www/page2.html"
2. data-url="/Users/bantonelli/Library/Application%20Support/iPhone Simulator/4.3.2/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/ATC%20QA.app/www/page2.html"

Note that this only occurs in iOS 4.x.

Is there any concern with unencoding the dataUrl var?