peterblazejewicz / blazor-beforeunload

Blazor hook into native Window beforeunload with async/await and cancel support
https://www.nuget.org/packages/BlazorBeforeUnload/
MIT License
20 stars 6 forks source link

This does not work in iOs #5

Closed Koski84 closed 1 year ago

Koski84 commented 1 year ago

Hi, this nugget works perfectly for any browser in windows but I can't make it work on iPad.

Is there any workaround or any hint to get it to work in iOs?

Thanks!

peterblazejewicz commented 1 year ago

@Koski84 I cannot help much, this was released as browser-specific version (some time ago) and I do not have insight, how Blazor stack is using this in the context of iPad (iOS). If that is a browser based web app, I'd connect debugger from your desktop to the Safari/Chrome on iPad and use developer tools to investigate problem (and to find a solution for your project).

Koski84 commented 1 year ago

Well, after researching a little more on this problem, it seems that the js beforeunload event is not supported in iOS.

I tried to make it work by using the pagehide event (which is the one that apple suggests to use instead of beforeunload) but then preventdefault method is not performing as expected there. No prompt is displayed and the navigation is not canceled.

I have not found any workaround to be able to cancel the navigation on the iPad.

peterblazejewicz commented 1 year ago

event seems to be supported, but event prevention is not: https://caniuse.com/mdn-api_window_beforeunload_event_preventdefault_activation