From 2135106b8a5ecc8a7fe38d495c5c3bc15b6f1259 Mon Sep 17 00:00:00 2001 From: EkkoLee <40066683+EkkoLee98@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:30:08 +0800 Subject: [PATCH] fix(iframe-page): iframe cors (#1312) Co-authored-by: EkkoLee98 --- src/components/IframePage.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/IframePage.vue b/src/components/IframePage.vue index ac41ec67..70360d21 100644 --- a/src/components/IframePage.vue +++ b/src/components/IframePage.vue @@ -27,7 +27,13 @@ onBeforeUnmount(() => { async function releaseIframeResources() { // Clear iframe content currentUrl.value = 'about:blank' - iframeRef.value?.contentWindow?.document.write('') + /** + * eg: When use 'iframeRef.value?.contentWindow?.document' of t.bilibili.com iframe on bilibili.com, there may be cross domain issues + * set the src to 'about:blank' to avoid this issue, it also can release the memory + */ + if (iframeRef.value) { + iframeRef.value.src = 'about:blank' + } await nextTick() iframeRef.value?.contentWindow?.close()