Fix a cross-origin frame access error in Translate.Web.setDocument
This commit is contained in:
parent
a5a7df328a
commit
dae0986b9b
1 changed files with 6 additions and 1 deletions
|
@ -1956,7 +1956,12 @@ Zotero.Translate.Web.prototype.Sandbox = Zotero.Translate.Sandbox._inheritFromBa
|
|||
*/
|
||||
Zotero.Translate.Web.prototype.setDocument = function(doc) {
|
||||
this.document = doc;
|
||||
this.rootDocument = doc.defaultView.top.document || doc;
|
||||
try {
|
||||
this.rootDocument = doc.defaultView.top.document;
|
||||
} catch (e) {
|
||||
// Cross-origin frames won't be able to access top.document and will throw an error
|
||||
this.rootDocument = doc;
|
||||
}
|
||||
this.setLocation(doc.location.href, this.rootDocument.location.href);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue