开发者

Javascript permission denied - different port

I have a rails app running on port 3000. The page in question has an iframe and I need to resize it depending on the height of the content loaded in the iframe.

<iframe id="ifrm_col3" name="ifrm_col3" frameborder="0" 
src="<%=invite_path(@invite.alias)%>" 
onload="util.resize_iframe('ifrm_col3');"></iframe>

The resize function is here:

util.resize_iframe = function(frame_id) {
  var h = document.getElementById(frame_id).contentWindow.document.body.scrollHeight;
  document.getElementById(frame_id).height = h; 
}

After the iframe loads, I see this error in FireBug:

Error: Permission denied for <http://192.168.0.157> to get property Window.document from <http://192.168.0.157:3000>.
Source File: http://192.168.0.157:3000/javascripts/application.js?1268327481
Line: 84

HTML rendered for the iframe looks like this:

<iframe id="ifrm_col3" name="ifrm_col3" frameborder="0" 
            src="/invite/my-invite-1" 
            onload="util.resize_iframe('ifrm_col3');"></iframe>

The src of iframe is a relative path, but I'm not sure why the port info from the parent page is not retained. Is there any workaround to this problem?

I tried creating a function in the parent page and calling it from the iframe, but ran into the same issue.

Due to extra开发者_如何学Go features in the site, I need to stick to port 3000 for the rails app.

Any suggestion is appreciated.


Are you quite sure that <%=invite_path(@invite.alias)%> does, in fact, output a relative path? That nothing has resolved it (incorrectly) along the way? What does the actual output to the src attribute end up looking like?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜