-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting notified about cancellation of the initial navigation. #256
Comments
This is not currently possible. However, I think we could consider making it work. The hard part is whether we want to treat the initial page load as special, or try to integrate it with the rest of the navigation API. Arguments for treating it as special: well, it is special. In particular:
So although it is tempting to try to do something clever here, e.g. making Another idea we've gotten in this space is whatwg/html#9090. Here's one idea: navigation.initialLoad.signal.addEventListener("abort", () => {
// initial page load was aborted
});
// Stop the loading indicator.
navigation.initialLoad.stopIndicator();
// Maybe this is the place to put https://github.com/whatwg/html/pull/1936,
// if people still want that:
await navigation.initialLoad.parsed;
await navigation.initialLoad.contentLoaded;
await navigation.initialLoad.subresourcesFullyLoaded;
// We could add some of the more informational properties of NavigateEvent, maybe?!
navigation.initialLoad.userInitiated;
navigation.initialLoad.navigationType;
navigation.initialLoad.formData; // this one could be a lot of work to implement, for POSTs |
This sounds good! |
I like the proposal on here! Another use-case which needs this is cross-document View Transition. The new Document needs to know the type of navigation to set up the UX (like swipe left/right if its a back/fwd navigation). A few aspects to think through:
|
Strongly agreed. Name suggestions welcome... Nothing is immediately coming to mind.
I think we can provide the whole previous entry, with a
That sounds great! In general, the promises I mentioned above (from whatwg/html#1936) kind of floundered on lack of use cases. So we should start with ones that have solid use cases, like your |
Same-origin is fine for now. We want to extend this feature to same-site eventually. Assuming both Documents opt-in, is there a reason the browser still can't allow same-site entries to be visible in the navigation API. |
Assuming both documents opt-in, this would be fine. |
Just to clarify my understanding: |
^ yes. The |
Created an HTML issue to continue evolving the proposal from the comment: whatwg/html#9760 |
We have a site that shows a loading screen on first page load, which is served in the html of the initial navigation, without running any scripts. We then download all the scripts and assets, which might take a while on slower connections. During this time the user is able to cancel the page load using the escape key.
But this can be a bit confusing, because when cancelling the page load, the text 'loading...' will stay visible forever, or until the page is refreshed. It doesn't help either that the escape key is also used to open the menu once the page has loaded.
So I'm trying to figure out a way to improve the user experience here. I was hoping there would be an event that I could listen for when the page load is cancelled. That way I could change the text to something else. Or maybe prevent the cancellation.
Right now the only thing that seems to work is listening for the 'Escape' key. But without being able to know for sure whether this caused the user agent to prevent loading, the best I can do is preventDefault the event:
The text was updated successfully, but these errors were encountered: