jack 3 недель назад
Родитель
Сommit
d8dcfb2317
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      src/views/Student/index.vue

+ 4 - 2
src/views/Student/index.vue

@@ -1861,6 +1861,7 @@ const handleHomeworkSubmit = async () => {
           const screenSlides = document.querySelectorAll('.viewer-canvas .screen-slide')
           let iframeElement: HTMLIFrameElement | null = null
           let iframeBody: HTMLElement | null = null
+          let iframehtml: HTMLElement | null = null
 
           // 获取iframe元素
           if (
@@ -1897,6 +1898,7 @@ const handleHomeworkSubmit = async () => {
             })
 
             iframeBody = iframeElement.contentWindow.document.body as HTMLElement
+            iframehtml = iframeElement.contentWindow.document.getElementsByTagName("html")[0] as HTMLElement
           }
           else {
             message.error(lang.ssFailedGetIframeBody)
@@ -1906,8 +1908,8 @@ const handleHomeworkSubmit = async () => {
           try {
             const a = iframeBody.getElementsByTagName('img')
             const b = iframeBody.getElementsByTagName('video')
-            iframeBody.style.width = '100vw'
-            iframeBody.style.height = '100vh'
+            iframeBody.style.cssText += 'width:100%;height:100%;position:absolute;top:0;left:0;'
+            iframehtml.style.cssText += 'width:100%;height:100%;position:absolute;top:0;left:0;'
             for (let i = 0;i < a.length;i++) {
               a[i].crossOrigin = 'anonymous'
             }