Javascript permission denied - different port
        Posted  
        
            by Grnbeagle
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Grnbeagle
        
        
        
        Published on 2010-03-12T15:55:01Z
        Indexed on 
            2010/03/12
            15:57 UTC
        
        
        Read the original article
        Hit count: 377
        
Hi,
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
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 features in the site, I need to stick to port 3000 for the rails app.
Any suggestion is appreciated.
© Stack Overflow or respective owner