I’m trying to access an iframe contents from the document it is contained in, but I’m getting the following error message:
Unsafe JavaScript attempt to access frame with URL
file:///home/user/work/project/foo.html from frame with URL
file:///home/user/work/project/index.html. Domains, protocols and
ports must match.
when I run this code:
$('#iframe_id').contents();
As you can see, both files are stored locally in the same folder, so can’t figure out why it is giving that error.
Chrome as security measures in place around local files. Meaning browsing local files isn’t the same as browsing a web server. I would try hosting them somewhere or install a local web server. There is also some command line switches for chrome to disable the local files security but I have never had much luck with it.
Edit:
comand-line switch as mentioned by El Ronnoco is –allow-file-access-from-files