I use some iframes in my page and I'd like to access iframe elements from parent page and the opposite.
From the parent page I add Iframes with:
<iframe id="iframe1" src="./iframe1.html" width="100%" height="100%"></iframe>
and I try di access iframe element by javascript with:
window.frames['iframe1']
...
From iframes I use something like
//to get elements
var obj = parent.document.getElementById('iframe1');
//to call methods
parent.document.mymethod();
In both situation it give me the following error:
Unsafe JavaScript attempt to access frame with URL file:///C:/Users/marco/test/iframe1.html from frame with URL file:///C:/Users/marco/test/index.html. Domains, protocols and ports must match.
I know that file have to be in the same domain. The problem is that I don't call files from web server, but browser has to read files directly from resource path. This because I will put theese files embedded in an Android app and I will read them with a webview from local resources. I tried to set manually window.domain = 'mydomain' but nothing changed and also to use absolute path for iframes.
I use Sencha Touch, if it can be usefull.
Any开发者_开发技巧 ideas? Thanks for your time,
Marco
精彩评论