0

내 사이트 www.drewgl.com에서 stumbleupon으로 일부 페이지를 추가하려고합니다. 그것은 매우 자바 스크립트에 의존합니다. stumbleupon을 통해 내 사이트를 볼 때 javascript가 차단됩니다. 특히, 오류가 표시됩니다.Stumbleupon Iframe에서 사이트 차단 javascript

Uncaught SecurityError: Blocked a frame with origin " http://www.drewgl.com " from accessing a frame with origin " http://www.stumbleupon.com ". Protocols, domains, and ports must match

저는 heroku에 배치 된 4 개의 레일을 사용하고 있습니다. 내 X- 프레임 옵션을 모두 허용하도록 설정했습니다. 여기에 답변을 읽어 보니 : SecurityError: Blocked a frame with origin from accessing a cross-origin frame 이 문제를 해결하는 유일한 방법은 window.postmessage를 사용하여 두 페이지간에 메시지를 보내는 것입니다. 그러나 이렇게하려면 두 페이지를 소유해야합니다.

물론 Stumbleupon에서는이 조건을 충족시킬 수 없으므로 어떻게 문제를 해결할 수 있습니까?

편집 : 방금 Chrome 용 stumbleupon 툴바를 다운로드했습니다. 이 작업을 수행 한 후 더 이상 위의 오류 메시지가 표시되지 않습니다. 어쨌든 툴바가없는 stumblers에 대해이 문제를 해결하고 싶습니다.

답변

0

알아 냈어. 호기심이 생기면 iframe 내에서 현재 경로에 액세스 할 수 없습니다. 이 코드 조각으로 인해 문제가 발생했습니다.

//  if (top.location.pathname === '/users/sign_in') 
// { 
//  $('#login').modal('show'); 
// } 
1

레일 앱이 StumbleUpon에로드되지 않았습니까? 귀하와 ApplicationController이 추가

before_action :allow_iframe_requests 

private 

    def allow_iframe_requests 
    response.headers.delete('X-Frame-Options') 
    end 

https://github.com/rails/rails/issues/6311