6

I am writing a html page using bootstrap3 template and including the respond.js in that, but when I run it on IE8, it gives me error "Access is denied" in console. I am using this to make IE8 support media queries. I have tried a lot of things as given on forums, but no luck. Does respond.js works locally or we need to run on a localhost/web server?

Respond.js link - https://github.com/scottjehl/Respond

HTML:

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="css/main.css" rel="stylesheet" media="screen">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.js"></script>
    <![endif]-->
  </head>
  <body>
  <div class="container">
    <h1>Hello, world!</h1>

    <div class="main-cont">         
    </div>
</div>        
    <script src="js/jquery-1.10.2.min.js"></script>        
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>

CSS - main.css

.main-cont {background:#2d3a42; height:100px;}
whyAto8
  • 1,660
  • 4
  • 30
  • 56

2 Answers2

9

Per the Respond.js Docs...

"Due to security restrictions, some browsers may not allow this script to work on file:// urls (because it uses xmlHttpRequest). Run it on a web server."

Specifically, "Respond.js re-requests the CSS files using Ajax and parses the text response," which is where IE's local security policy is blocking you. Another user elsewhere suggested changing the security settings in IE, but I can't confirm that solution since my copy of IE8 doesn't permit me to change those settings.

Oh, and to save you the trouble, I already tested and confirmed that using ajaxSetup() method in jQuery to set "isLocal" property to "true" won't overcome the local restriction in IE.

Community
  • 1
  • 1
Phil Nicholas
  • 3,681
  • 1
  • 19
  • 23
6

I just managed to make respond.js run on IE8 for media queries support , by running on localhost. If simply the html file opened, it does not help.

whyAto8
  • 1,660
  • 4
  • 30
  • 56
  • 1
    I actually linked to a respond.js file using an absolute link in the header to one residing on someone else's web server but I still get the "access is denied" error when viewing the site locally. Is that not one work-around to getting it to work without a local webserver? – redshift Oct 22 '13 at 01:38
  • Well, I am not too sure if this would be a work around. I just tried running on local host and it started working. – whyAto8 Oct 22 '13 at 08:53
  • This does not work for me -- access is denied locally in localhost or if I use remote scripts. – jimiayler Oct 06 '14 at 14:53