PDFElement: event property

Works in all major browsers
Since July 2026

WebPDF works in Chrome and Edge 125, Firefox 153 and Safari 18, on desktop and mobile, and in every later version: the oldest versions its PDF.js build supports, which already have every platform feature WebPDF needs. Since July 2026, that is every major browser.

The event property of the PDFElement interface returns an object with which <pdf-file> and <pdf-page> elements choose the names of the events they fire. Its prefix property reflects the event:prefix HTML attribute.

Value

An object with one property:

prefix

A string: this element's own event:prefix, or "" when it has none (and inherits). The only value that does anything is "type": events are then named after the element, so load becomes pdf-file-load or pdf-page-load. "-" turns an inherited prefix off.

The attribute is multi-homed: it works on the WebPDF <script>, on every <pdf-file> and on every <pdf-page>, and the nearest one wins.

The prefix is read when an event fires, so a change applies to the next event.

Examples

Telling file and page events apart

Page events bubble through their file, so prefixes make the two easy to tell apart:

html
<script src=//new.webpdf.pro/.js type=module event:prefix=type></script>
js
document.addEventListener("pdf-file-load", (event) => console.log("file", event.target));
document.addEventListener("pdf-page-load", (event) => console.log("page", event.target));

Specifications

Not part of any specification. <pdf-file> and <pdf-page> are autonomous custom elements defined by WebPDF.pro.

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
event
1251251531111812515383182712518

Legend

Full support

See also