From 0644bdbf14e7f1bbe48fcc18a81aa39ffc2eb323 Mon Sep 17 00:00:00 2001 From: "David J. Bradshaw" Date: Sat, 25 May 2024 11:39:02 +0100 Subject: [PATCH] Add check for user set iframe title #1255 --- example/html/index.html | 1 + packages/core/index.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/example/html/index.html b/example/html/index.html index c26b1788c..02b84e9a0 100644 --- a/example/html/index.html +++ b/example/html/index.html @@ -32,6 +32,7 @@

Automagically resizing iFrame

src="../child/frame.content.html" width="100%" scrolling="no" + title="iframe-resizer content examples" >

diff --git a/packages/core/index.js b/packages/core/index.js index 54565e4cb..0ae8c646f 100644 --- a/packages/core/index.js +++ b/packages/core/index.js @@ -481,7 +481,7 @@ See https://iframe-resizer.com/setup/#child-page-setup for more details. } function setTitle(title, iframeId) { - if (!settings[iframeId]) return + if (!settings[iframeId]?.syncTitle) return settings[iframeId].iframe.title = title log(iframeId, `Set title attribute to: ${title}`) } @@ -1045,6 +1045,11 @@ The sizeWidth, sizeHeight and autoResize options have been rep settings[iframeId].postMessageTarget = iframe.contentWindow } + function chkTitle(iframeId) { + const { title } = document.getElementById(iframeId) + return title === '' + } + function processOptions(options) { settings[iframeId] = { iframe, @@ -1053,6 +1058,7 @@ The sizeWidth, sizeHeight and autoResize options have been rep ...defaults, ...checkOptions(options), mode: setMode(options), + syncTitle: chkTitle(iframeId), } setDirection()