Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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>
share|improve this question
    
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 Aug 19 '13 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 Aug 19 '13 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. –  bybe Aug 19 '13 at 11:44
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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