Updating a http parent page from a https page via Javascript

十年热恋 提交于 2019-12-12 23:32:03

问题


I have a unsecure page which opens up a secure (https) page. The secure page needs to update the parent page via a javascript submit() while still remaining the current window. However when I try to do this via javascript I get an "Access Denied" javascript error because the parent page is unsecure.

Any idea of how I can access the parent page, when it isn't secure?

Here is the javascript code that I'm using to perform the submit...

self.opener.parent.frames.item('BODY').document.forms[0].submit();


回答1:


Same-Origin-Policy in browsers means that you cannot do this directly. The "Origin" is composed of Scheme/Protocol and Hostname. In your case, the scheme mismatches, so the cross-document request is blocked.

You can use explicity x-frame communication techniques (Fragment Identifier Messaging or HTML5 PostMessage) to send a message to the outer page to execute an event-handler.



来源:https://stackoverflow.com/questions/1125238/updating-a-http-parent-page-from-a-https-page-via-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!