browser-compat-data icon indicating copy to clipboard operation
browser-compat-data copied to clipboard

Safari for IOS 17.3.1 does not support `beforeunload` event

Open akylc opened this issue 1 year ago • 9 comments
trafficstars

MDN URL

https://developer.mozilla.org/docs/Web/API/Window/beforeunload_event

What specific section or headline is this issue about?

Browser compatibility

What information was incorrect, unhelpful, or incomplete?

The beforeunload event's compatibility data related to "Safari for iOS" is not corrected.

What did you expect to see?

The BCD shows that the event is not supported on Safari for iOS, or a note about this.

Do you have any supporting links, references, or citations

https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5

Do you have anything more you want to share

No response

MDN metadata

Page report details
  • Folder: zh-cn/web/api/window/beforeunload_event
  • MDN URL: https://developer.mozilla.org/zh-CN/docs/Web/API/Window/beforeunload_event
  • GitHub URL: https://github.com/mdn/translated-content/blob/main/files/zh-cn/web/api/window/beforeunload_event/index.md
  • Last commit: https://github.com/mdn/translated-content/commit/7d0e3ea245f84dd38b0a1b6203b4b90672d6ab07
  • Document last modified: 2023-08-04T07:43:54.000Z

akylc avatar May 07 '24 08:05 akylc

Hello @akylc. Could you provide additional documentation about the support of this event has been removed? The documentation currently provided may not be accurate (it is archived and may be out of date) as I was also able to find this event in the latest code of WebKit: https://github.com/search?q=repo%3AWebKit%2FWebKit%20beforeunload&type=code

yin1999 avatar May 08 '24 01:05 yin1999

it's a property exists on window by default value null (instead of undefined) in mobile Safari, see:

image

but it will not be fired, as it's not in the supported events table, (possibly) from the very-beginning

Screenshot 2024-05-15 at 12 25 42 PM

researching has begun since 5years ago, see: https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad

PassionPenguin avatar May 15 '24 04:05 PassionPenguin

I've tested this event on iOS 17.4.1 and failed to trigger the event handler during testing. But I can't find any recent official document showing that this event cannot be triggered.

yin1999 avatar May 15 '24 14:05 yin1999

Hey @queengooborg. Sorry to bother you, I was indeed unable to trigger the beforeunload event during my test, but I can't confirm the actual support for this event on Safari for iOS. Could you confirm this or provide some help :)

yin1999 avatar May 16 '24 02:05 yin1999

found a doc in WebKit JS: onbeforeunload | ADD, said that it's supported ever since Safari Mobile 9.0+

PassionPenguin avatar May 16 '24 03:05 PassionPenguin

I found the WebKit Bug 219102 which reported the issue on Safari for IOS.

Hey @bsmth. I'm not sure what should we do for this case. Could you give any suggestions (i.e. should we provide a note for it in mdn/content or in mdn/browser-compat-data) :)

yin1999 avatar Sep 09 '24 01:09 yin1999

Thanks for tagging me. It looks like a BCD issue, there's some notes about mobile usage here already: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event#usage_notes

Was it fully unsupported before WebKit Bug 219102 or only in certain cases? I will transfer over to BCD for now, ty.

bsmth avatar Sep 09 '24 10:09 bsmth

BCD for this originally added in:

  • [x] https://github.com/mdn/browser-compat-data/pull/3639

bsmth avatar Sep 09 '24 10:09 bsmth

Thanks for tagging me. It looks like a BCD issue, there's some notes about mobile usage here already: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event#usage_notes

Was it fully unsupported before WebKit Bug 219102 or only in certain cases? I will transfer over to BCD for now, ty.

Hi. The event was still fully unsupported till now on iOS 16. 17 and 18 Safari browsers, same on documentation of WebKit (see comment above)

PassionPenguin avatar Sep 09 '24 11:09 PassionPenguin