2

I am trying to load a local html file within an iframe but nothing happens. I hear this is a security feature of my OS (windows 8). I am designing a website that is not domain registered yet and need to load this local html file within my iframe as it contains my menu bar which i do not want to copy and past to all 8 (currently unhosted) webpages, as this would make further customization tedious.

Does anyone know the correct syntax to load a local file (one that is actually stored on the same computer) and/or the security settings I may have to change?

<iframe scr="file:///C:/Users/davey666/Desktop/Dion/menu.html"> </iframe>
3
  • The problem seems to have spontaneously corrected itself. After trying to run my html in safari instead of chrome the iframe loaded and it now loads in chrome also. I have read in multiple places that this hiccup is the result of a security feature but cannot find any specific documentation concerning it. I also do not fully understand how opening in a different browser solved the problem.
    – Dion Jones
    Commented Aug 19, 2013 at 3:51
  • Problem still persists using the identical code and (equivalent) directory path on my other windows 7 machine(with both the html documents residing in a single folder on that machine). Anyone know any fixes for this? Syntax and directories are flawless and triple checked :/. I am inclined to believe this is a security measure or possibly an eccentricity of the web browser (chrome)
    – Dion Jones
    Commented Aug 19, 2013 at 4:04
  • It's because its local using file:// which is not supported you'd need to follow Gronostaj method. Ideally you should never test iframes locally. And to be honest there should be no need to use iframes on same site content just use php include. Commented Aug 19, 2013 at 11:44

2 Answers 2

2

It's a security feature of Chrome.

Preferred solution: use relative paths, just as you do with <a> tags.

Temporary pseudo-solution: run Chrome with --allow-file-access-from-files switch. It will make it work, but that's not a real solution, because the real cause of the problem is you using absolute local paths.

1

I know this is old, but you've also put "scr" instead of "src" in front of the link.

1
  • Nice catch. Nobody else pointed that out Commented Jun 5, 2020 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.