为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Is it possible to view websites from local hard drive

  • 6 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 Peter Pan

more options

I like to test my web pages as much as possible at home before uploading to a server. I do this by setting up empty drive partitions for my various sites, so that 'root level" access will work similarly on a server or from the hard drive. So, for example, a line on a page like...

<script src="/scripts/siteScripts2.js"> </script>

or

<link rel="stylesheet" type = "text/css" href="/styles/fonts/fonts.css"> <link rel="stylesheet" type = "text/css" href="/styles/spcPageStyles1.css" >

Will reference the files from the root level, as if it was on a server.This works all the time with Chrome and IE, even back to IE-8. So Mozilla Firefox must be blocking file references from local hard Drive root level. If there is a config variable or two I can set to allow it from firefox, I'd appreciate knowing about it. I'm satisfied testing with Chrome and IE, but FF is an important browser to test with.

Thanks in advance!

I like to test my web pages as much as possible at home before uploading to a server. I do this by setting up empty drive partitions for my various sites, so that 'root level" access will work similarly on a server or from the hard drive. So, for example, a line on a page like... <script src="/scripts/siteScripts2.js"> </script> or <link rel="stylesheet" type = "text/css" href="/styles/fonts/fonts.css"> <link rel="stylesheet" type = "text/css" href="/styles/spcPageStyles1.css" > Will reference the files from the root level, as if it was on a server.This works all the time with Chrome and IE, even back to IE-8. So Mozilla Firefox must be blocking file references from local hard Drive root level. If there is a config variable or two I can set to allow it from firefox, I'd appreciate knowing about it. I'm satisfied testing with Chrome and IE, but FF is an important browser to test with. Thanks in advance!

被采纳的解决方案

'Root' level access via "/styles/fonts/fonts.css" works relative to the folder where the HTML file is located. You can't go back in the directory tree to access other folders starting with root.

定位到答案原位置 👍 1

所有回复 (6)

more options

If you writing your own page there should be something in the software you using to preview or test the page. You should check with the software maker your using to write your web page to see if they have a built in function to do that. I know most should as this helps them revise or redo pages before uploading as well.

more options

Thanks @Westend, but since both Chrome and IE (at least older versions) do allow you to properly load and view a site on your local drive, and even treat "root level" links as if they just referred to the root level of the hard drive (EG: D:\ or E:\), I'd just like to know why I can't do the same with Firefox, and whether there is a simple configuration change that will allow it.

I'm a hand coder so there is no special software I use for development. But even if I did, when I say "test" pages, I mean I like to see how the page will appear in various browsers and versions of browsers. Even if I used special software that allowed a browser view, it would not accurately simulate Chrome, Firefox, IE (various versions) or safari. If all browsers identically implemented CSS and their internal DOM, testing with just one browser would be enough.

more options

选择的解决方案

'Root' level access via "/styles/fonts/fonts.css" works relative to the folder where the HTML file is located. You can't go back in the directory tree to access other folders starting with root.

more options

cor-el said

'Root' level access via "/styles/fonts/fonts.css" works relative to the folder where the HTML file is located. You can't go back in the directory tree to access other folders starting with root.

Yes...thanks... I've found that too. while updating my pages, I'd heard repeatedly (though I don't know why) that it better to reference things to the root, and even use full URLs. I didn't do the latter, but I did start referencing all resources to the "/" root, and thans when it broke Firefox's ability to render the pages with links styles and JS scrips. Its just odd that Chrome and the lowly IE (at least my versions) do allow it. I guess I'll just live with it. Thanks.

more options

Note that I've purposely dedicated a drive partition entirely to the site I'm working on. So If the site page is at E:\mypage.html, a link to ""/styles/fonts/fonts.css" should work, because that is EXACTLY where the fonts.css file is. And as i said, it WORKS in Chrome and IE. But not in FF!

more options

Finally, I'm sure at this point that the inability of FF to access the kind of embedded links to root level resources I've described is NOT a bug, but intentional. I'm sure it is a security measure. So what I would like to know is, how do i request the software authos reconsider this block, and and allow developers (who surely KNOW the risks ) to override it with a setting or config variable?