ID Attribute
October 1, 2020
The id
attribute is widely used to identify HTML
elements. Unfortunately, cross-origin websites can determine whether a given id
is set anywhere on a page by leveraging the focus
event and URL
fragments. If https://example.com/foo#bar
is loaded, the browser attempts to scroll to the element with id="bar"
. This can be detected cross-origin by loading https://example.com/foo#bar
in an iframe; if there is an element with id="bar"
, the focus
event fires. The blur
event can also be used for the same purpose 1.