less.js icon indicating copy to clipboard operation
less.js copied to clipboard

ie + file:/// = "Access denied"

Open kbabintsev opened this issue 15 years ago • 11 comments

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>less</title>
        <link rel="stylesheet/less" type="text/css" href="main.less">
        <script type="text/javascript" src="less-1.1.4.js">
        </script>
    </head>
    <body>
    </body>
</html>
body
{
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: red;
}

Error "Access denied" when trying to open html using file protocol (file:///C:/Projects/index.html). It's work fine with ActiveXObject implemetation of XMLHttpRequest.

function getXMLHttpRequest() {
    if (window.XMLHttpRequest 
       // This is solution?
       && !(window.ActiveXObject && isFileProtocol)
    ) {
        return new(XMLHttpRequest);
    } else {
        try {
            return new(ActiveXObject)("MSXML2.XMLHTTP.3.0");
        } catch (e) {
            log("browser doesn't support AJAX.");
            return null;
        }
    }
}

kbabintsev avatar Aug 23 '11 06:08 kbabintsev

http://stackoverflow.com/questions/2142156/read-file-urls-in-ie-xmlhttprequest/2753160#2753160

ttfkam avatar Aug 23 '11 16:08 ttfkam

I also would like this issue to be resolved as it would enable our developpers/designers to edit less files and see the reuslts without having to run a webserver.

bertBruynooghe avatar Oct 18 '11 08:10 bertBruynooghe

Unfortunately, this issue cannot be resolved by Less. Web browsers have very strict rules about arbitrary requests to the local filesystem -- for good reason. That said, Macs come preconfigured with a web server, Linux & BSD web servers are extremely easy to install, and both nginx and apache have Windows installers. On my Windows machine, I run nginx; very low memory and just a double-click of an icon to start it.

ttfkam avatar Oct 18 '11 17:10 ttfkam

Not good news. We creating offline (local) application that uses file protocol and all major js libs works... jQuery for example with AJAX requests to local resources (files)...

kbabintsev avatar Oct 19 '11 02:10 kbabintsev

@kbabintsev my apologies, I misspoke. Assuming this is the IE7/8 issue I think it is, it could be resolved in Less. I was completely mistaken with regard to local resources. Again, sorry.

ttfkam avatar Oct 20 '11 17:10 ttfkam

I'd like to get this issue fixed too.

imeleshkov avatar Oct 28 '11 15:10 imeleshkov

anyone like to suggest what that fix is?

lukeapage avatar Sep 02 '12 17:09 lukeapage

The fix suggested in this answer looks workable, but would increase the overall number of requests in IE (though that's its fault for being broken!). To integrate it we'd need to rewrite the xhr function to work this way.

Synchro avatar Sep 03 '12 09:09 Synchro

Hi, I had the same problem and I sent you another way to fix it: https://github.com/Scorpin/less.js/commit/ee2c1a1bcbd500b4d1c1aca8f84a7d4e12c9b68e

Greetings.

Scorpin avatar Oct 12 '13 21:10 Scorpin

According to the attached Stack Overflow links, this was only an issue in IE7 / IE8. Should probably consider closing by now.

matthew-dean avatar Mar 04 '16 17:03 matthew-dean

Closing as not applicable anymore (let MS care of their ancient stuff on their own).

seven-phases-max avatar May 23 '17 15:05 seven-phases-max