Is History API broken on iOS? (Location bar doesn't update on pushState)
So the bottom line is that iOS has added its own security around the history API, meaning that you can't use script to change the url. Only a user action can allow the history API to change the url - i.e. a click - as per Aral's example.
The workaround is to uses a hash (aka fragment identifier) on the url.
Instead of the history.pushState
we'll just change the location:
var i = 0;
var locationUpdateInterval = setInterval(function(){
window.location.hash = i;
i++;
}, 1000);
To capture the event either when something changes the that location in the iOS app or if they have permalink to a particular page/panel in your app:
// named function on purpose for later
function hashchange() {
var pageId = location.hash.substr(1); // drop the # symbol
// do something with pageId
}
window.onhashchange = hashchange;
// onload - if there's a hash on the url, try to do something with it
if (location.hash) hashchange();
It's pretty poor that we can't use the pushState
/popState
on iOS, but it's the same security as not being able to trigger fullscreen video unless the user initiates the action, which is the same as downloading video or audio content on iOS - you can't script it, the user must start it (somehow or another).
Just as a note about Android - the problems are pretty similar, so this (should) also work as a workaround for Android.
If you want desktop support, most browsers support onhashchange
but, yep, you guessed, IE is lacking behind - so you can polyfill that bad boy in (though requires jQuery...): http://benalman.com/projects/jquery-hashchange-plugin/
Hope that helps.
Html5 History Api - pushState from a domain to a subdomain
It can't be done. This is by design. There are no exceptions.
From the Mozilla pushState documentation:
The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception.
pushState problem Framework7 v3.5.2 doesn't load the view
Look at this:
view: {
pushState: true,
pushStateSeparator: '#',
pushStateOnLoad: false
}
You had to remove the pushStateRoot
Parameter, that was a good call.
But you also have to insert pushStateSeparator
, this let you navigate in the right url (without '#').
You need to use pushStateOnLoad
too. This one let you "Disable to ignore parsing push state URL and loading page on app load."
For more see the documentation.
Related Topics
How to Schedule Mail Using Gmail API
How to Check Bitfields (Scnetworkreachabilityflags in Particular) for Flags in Swift
Error When Instantiating a UIfont in an Text Attributes Dictionary
Cocoapods Page Redirecting to Github
Progress of a Alamofire Request
Cfbundledocumenttype Is Not Working in Myproject-Info.Plist File
Multiple Lines in UItabbaritem Label
Added a Custom Framework, Now Swift Can't Unarchive Data
Swift - Weekday by Current Location by Currentcalendar()
Retrieve All Child Value to a Label in Table View Cell
Filter Array of Custom Objects in Swift
Realm Crashes with Rlmexception: Object Has Been Deleted or Invalidated
Does "Let _ = ..." (Let Underscore Equal) Have Any Use in Swift
Sprite Frame Animation Cocos2D 3.0
Spritekit Not Respecting Zposition
How to Show Viewcontroller from a Non-Viewcontroller Helper Class
Atos Does Not Symbolicate System Frameworks/Libraries Properly