Does onresize="" work on <body>?
MDN URL
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
What specific section or headline is this issue about?
The onresize="" attribute
What information was incorrect, unhelpful, or incomplete?
I was looking through the docs on
and reading about onresize="". The docs for says it works fine. But when I clicked to the Window 'resize' event documentation, I found this quote:In some earlier browsers it was possible to register resize event handlers on any HTML element. It is still possible to set onresize attributes or use addEventListener() to set a handler on any element. However, resize events are only fired on the window object (i.e. returned by document.defaultView). Only handlers registered on the window object will receive resize events.
Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event
So just wondering if the 'resize' event works for
tags or not? Seems like one of the pieces of the documentation should be updated whatever the case. I did a little test using and it seemed to receive the 'resize' event just fine. So maybe the documentation for Window: resize event should be updated?What did you expect to see?
Docs that are the same for
onresize="" and Window 'resize' eventDo you have any supporting links, references, or citations?
Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event
Do you have anything more you want to share?
No
MDN metadata
Page report details
- Folder:
en-us/web/html/element/body - MDN URL: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/html/element/body/index.md
- Last commit: https://github.com/mdn/content/commit/8fbec5312b62d720f6ff6936024a09c859f2f0f1
- Document last modified: 2024-11-12T19:17:48.000Z
onresize can be set on body to listen for the events that fire on Window, because it is a Window-reflecting body element event handler set. This is a duplicate of https://github.com/mdn/content/issues/34684; we'll make sure to explain this concept (and related event proxying mechanisms) well.