Ver código fonte

fix snapshot_live iframe scrollTo not working due to origin sandbox rules

Nick Sweeting 1 ano atrás
pai
commit
729f05ab93
1 arquivos alterados com 4 adições e 2 exclusões
  1. 4 2
      archivebox/templates/core/snapshot_live.html

+ 4 - 2
archivebox/templates/core/snapshot_live.html

@@ -435,12 +435,14 @@
                     this.src = this.src + '#toolbar=0'
                     this.src = this.src + '#toolbar=0'
                 }
                 }
                 this.onload = function() {
                 this.onload = function() {
-                    this.contentWindow.scrollTo(0, 0);
-                    // this.src = this.src
                     if (this.src.endsWith('.pdf')) {
                     if (this.src.endsWith('.pdf')) {
                         this.removeAttribute('sandbox')
                         this.removeAttribute('sandbox')
                         this.src = this.src + '#toolbar=0'
                         this.src = this.src + '#toolbar=0'
                     }
                     }
+                    try {
+                        // doesnt work if frame origin rules prevent accessing its DOM via JS
+                        this.contentWindow.scrollTo(0, 0);
+                    } catch(err) {}
                 }
                 }
             })
             })