fix: TOC PDF - forcer le rechargement de l'iframe (BUG-063 complement)
This commit is contained in:
@@ -521,10 +521,12 @@ function applyPrettyHighlight(codeEl, lang, text) {
|
||||
/**
|
||||
* Jump the inline PDF viewer to a specific page.
|
||||
*
|
||||
* The browser's built-in PDF viewer lives in an ``about:blank`` content window,
|
||||
* so assigning ``contentWindow.location.hash`` never reaches the document (the
|
||||
* TOC links used to do exactly that and did nothing). Reloading the iframe with
|
||||
* the ``#page=N`` fragment is the supported way to target a page.
|
||||
* The browser's built-in PDF viewer lives in an ``about:blank`` content window
|
||||
* (so ``contentWindow.location.hash`` never reaches the document) **and** it
|
||||
* ignores a same-document fragment navigation: changing only ``#page=N`` on the
|
||||
* iframe ``src`` does not move the page. A changing query parameter forces a
|
||||
* real reload, and the ``#page=N`` fragment is then honoured at load — the only
|
||||
* reliable way to target a page with the native viewer.
|
||||
*
|
||||
* @param {HTMLElement} area - Content area containing the ``.pdf-iframe``.
|
||||
* @param {string|number} page - 1-based page number from the PDF outline.
|
||||
@@ -534,7 +536,8 @@ export function navigatePdfToPage(area, page) {
|
||||
if (!iframe || page === null || page === undefined || page === '') return;
|
||||
const base = iframe.getAttribute('data-pdf-url') || iframe.src.split('#')[0];
|
||||
iframe.setAttribute('data-pdf-url', base);
|
||||
iframe.src = `${base}#page=${page}`;
|
||||
const sep = base.includes('?') ? '&' : '?';
|
||||
iframe.src = `${base}${sep}_pdfpage=${Date.now()}#page=${page}`;
|
||||
}
|
||||
|
||||
export function renderFile(data) {
|
||||
|
||||
Reference in New Issue
Block a user