我知道這是一個跨瀏覽器通信或同源策略的問題,瀏覽器不允許這樣的通信。從Iframe調用父窗口方法
我需要一個圍繞此用例的工作。我在HTTP中有一個父頁面,從那裏我將表單提交給HTTPS,我的要求是不要離開頁面,表單打開覆蓋。
這是我目前的JSP設置
<form:form action="https://localhost:9002/myApp/springSecurity/login" class="login-form error-info" id="loginForm" method="post" commandName="loginForm" target="guestFrame">
<iframe width="0" frameborder="0" scrolling="no" name="guestFrame" >
從我發送Java的腳本在響應中的I幀被追加服務器,這是Java腳本從服務器發送
<html><body>"+ "<script type=\"text/javascript\">parent.handleResponse('error',securityLoginStatus.getLoginFailedException());</script>"+ "</body></html>")
我已經定義在父窗口即handle-response
的方法,但我在瀏覽器中獲取以下錯誤
Permission denied to access property 'handleResponse'
我甚至嘗試與parent.wwindow.handleResponse
但得到相同的錯誤。 有什麼辦法可以與iframe中的父窗口進行通信?
我假設'parent.wwindow'也是一個錯字。 –
是的,這只是一個錯字:)在實際的代碼中,它的父代' –
嘗試'window.top.handleResponse'。 –