In my application I am using window.history.back to navigate back to previous View
Declaration of back button
<div class="back_icon" id="verification_back_icon"><a href="#" data-rel="back" data-transition="slidedown"><img src="images/back_btn.png" width="23"/></a></div>
Button action:
$("#verification_back_icon").on("click", function(e)
{
if(checkDirtyVacation())
{
e.preventDefault();
if(backbtnAlt== false)
{
backbtnAlt =true;
confirm("All data will be lost. Do you want to continue?",
function(r){
if(r){
//onBackKeyDown();
clearVacationvalues();
window.history.back();//this is not working in iOS 9
}else{
}
backbtnAlt =false;
});
}
}
else
{
e.preventDefault();
if($(".vaction_location").hasClass("chkSelect"))
{
$(".vaction_location").removeClass("chkSelect");
$(".vaction_location").addClass("chkUnSelect");
}
window.history.back();
}
});
This worked perfectly till iOS 8.4. In iOS 9 this navigation is not working.
I am using Apache Cordova native platform version 3.8.0
.
If anyone facing the similar problem please suggest me. I have tried with history.back doesn't work on iOS using Cordova, but no luck
Thank you.
Try this
SOLUTION:
This line resolved my issue :
I have replaced
window.history.back()
withhistory.go(0);
Now it is working fine for me in iOS 9
In index.html
Add this in onDeviceReady function:
Validation for device OS version (as
history.go(0)
is working only with iOS 9) Prior to iOS 9 versionwindow.history.back()
working perfectlyAnd now Add this piece of code in place of window.history.back()
To fix this Message "Failed to load webpage with error: CDVWebViewDelegate: Navigation started when state=1" in console add below code in CDVWebViewDelegate.m
Method Comment this piece of code shown below:
I think it is the A tag's default action causes the bug. So I just prevent the default action by adding
return false
at end of the click handler functionAnd it works.
<a id="back-btn">back</a>
javascript
The problem is that setting of
window.location.hash
is asynchronous in the iOS 9.0 UIWebview (used by Cordova/Phonegap) - see this bug report for details.This causes issues when using jQuery Mobile which by default uses
window.location.hash
to navigate between "pages". It also causes issues with popups/dialogs/select menus which use this mechanism.You can fix this by preventing jQuery Mobile from automatically listening/using location.hash:
However, I found this had side effects on Android such as causing the hardware back button not to work, so I targeted it specifically at iOS 9 using cordova-plugin-device:
Note that I'm using
navigator.app.backHistory()
notwindow.history.back()
in conjunction withhashListeningEnabled = false
- this may make a difference.Alternatively you can use this plugin to use the new WKWebView on iOS 8 and 9. WKWebView is used by Safari on iOS 8+, hence JQM sites viewed in the browser on iOS 9 don't encounter these issues. cordova-ios 3 still uses UIWebView due to a bug in WKWebView in iOS 8, but the upcoming cordova-ios 4 will support a WKWebView core plugin for iOS 9+. Note that there are additional considerations when using WKWebView with Cordova/Phonegap apps due to its stricter security, such as requiring CORS headers on XHR responses.
Disabling push state worked for me:
$.mobile.pushStateEnabled = false;
@Sujania,
According to the phonegap team, iOS9 is not officially support. This issue may be yet another bug in iOS9. You may have to wait for a fix.
PhoneGap Build iOS 9 Support Status
http://community.phonegap.com/nitobi/topics/phonegap-build-ios-9-support-status
At this point in time, 4 bugs are reported to the Cordova Bug repository. Your issue does not appear in the respository - as of this date.
https://issues.apache.org/jira/browse/CB-9684?jql=text%20~%20%22iOS9%22