When I access my aspx page in chrome or safari it shows this error in console
Not allowed to load local resource: file:///D:/CSS/Style.css
The solution is already answered here above (long ago).
But the implicit question "why does it work in FF and IE but not in Chrome and Safari" is found in the error text "Not allowed to load local resource": Chrome and Safari seem to use a more strict implementation of sandboxing (for security reasons) than the other two (at this time 2011).
This applies for local access. In a (normal) server environment (apache ...) the file would simply not have been found.
It is today possible to configure Safari to access local files.
- By default Safari doesn't allow access to local files.
- To enable this option: First you need to enable the develop menu.
- Click on the Develop menu Select Disable Local File Restrictions.
Source: http://ccm.net/faq/36342-safari-how-to-enable-local-file-access
You wont be able to access a local resource from your aspx page (web server). Have you tried a relative path from your aspx page to your css file like so...
<link rel="stylesheet" media="all" href="/CSS/Style.css" type="text/css" />
The above assumes that you have a folder called CSS
in the root of your website like this:
http://www.website.com/CSS/Style.css
I know this post is old but here is what I found.
It doesn't work when I link it this way(with /
before css/style.css
on the href
attribute.
<link rel="stylesheet" media="all" href="/CSS/Style.css" type="text/css" />
However, when I removed /
I'm able to link properly with the css file
It should be like this(without /
).
<link rel="stylesheet" media="all" href="CSS/Style.css" type="text/css" />
This was giving me trouble on my project. Hope it will help somebody else.