最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Respond.js not working cross domain - Stack Overflow

programmeradmin4浏览0评论

I'm having difficulty getting Respond's CDN/X-Domain Setup working.

I started off serving all assets from the CDN:

<link rel="stylesheet" href=".css?2013012401">
<script src=".6.2.min.js?2013012401"></script>
<script src=".min.js?2013012401"></script>

In theory this should work, since all assets are being served from the same domain. However IE8 didn't receive Media Query support like it should. So I investigated Respond's CDN/X-Domain Setup and amended my <head> section to this:

<link rel="stylesheet" href=".css?2013012401">
<script src=".6.2.min.js?2013012401"></script>
<script src=".min.js?2013012401"></script>
<link href=".html?2013012401" id="respond-proxy" rel="respond-proxy">
<link href=".proxy.gif?2013012401" id="respond-redirect" rel="respond-redirect">
<script src=".proxy.js?2013012401"></script>

When that also failed, I amended my <head> section to this:

<link rel="stylesheet" href=".css?2013012401">
<script src=".6.2.min.js?2013012401"></script>
<script src=".min.js?2013012401"></script>
<link href=".html?2013012401" id="respond-proxy" rel="respond-proxy">
<link href="/img/respond.proxy.gif" id="respond-redirect" rel="respond-redirect">
<script src="/js/respond.proxy.js"></script>

I'm not sure what else I can try really to get this to work. It works fine in a local Dev environment that's not using the CDN, but in the Live environment this Respond.js CDN/X-Domain Setup is not working. Could it possibly be related to the cache-buster query string added to the CDN assets? Why is my original example not working when all assets are being served from the same domain?

Edit: Here's the error that's thrown in IE8

I'm having difficulty getting Respond's CDN/X-Domain Setup working.

I started off serving all assets from the CDN:

<link rel="stylesheet" href="http://cdn.example./css/main.css?2013012401">
<script src="http://cdn.example./js/modernizr-2.6.2.min.js?2013012401"></script>
<script src="http://cdn.example./js/respond.min.js?2013012401"></script>

In theory this should work, since all assets are being served from the same domain. However IE8 didn't receive Media Query support like it should. So I investigated Respond's CDN/X-Domain Setup and amended my <head> section to this:

<link rel="stylesheet" href="http://cdn.example./css/main.css?2013012401">
<script src="http://cdn.example./js/modernizr-2.6.2.min.js?2013012401"></script>
<script src="http://cdn.example./js/respond.min.js?2013012401"></script>
<link href="http://cdn.example./respond-proxy.html?2013012401" id="respond-proxy" rel="respond-proxy">
<link href="http://cdn.example./img/respond.proxy.gif?2013012401" id="respond-redirect" rel="respond-redirect">
<script src="http://cdn.example./js/respond.proxy.js?2013012401"></script>

When that also failed, I amended my <head> section to this:

<link rel="stylesheet" href="http://cdn.example./css/main.css?2013012401">
<script src="http://cdn.example./js/modernizr-2.6.2.min.js?2013012401"></script>
<script src="http://cdn.example./js/respond.min.js?2013012401"></script>
<link href="http://cdn.example./respond-proxy.html?2013012401" id="respond-proxy" rel="respond-proxy">
<link href="/img/respond.proxy.gif" id="respond-redirect" rel="respond-redirect">
<script src="/js/respond.proxy.js"></script>

I'm not sure what else I can try really to get this to work. It works fine in a local Dev environment that's not using the CDN, but in the Live environment this Respond.js CDN/X-Domain Setup is not working. Could it possibly be related to the cache-buster query string added to the CDN assets? Why is my original example not working when all assets are being served from the same domain?

Edit: Here's the error that's thrown in IE8

Share Improve this question edited Jan 21, 2014 at 20:26 Kara 6,22616 gold badges53 silver badges58 bronze badges asked Jan 28, 2013 at 14:22 Alec RustAlec Rust 11.4k14 gold badges51 silver badges64 bronze badges 2
  • Having the same issue :-/ Did the CDN/X-Domain Setup, but now it throws a JavaScript error: respond variable not found on line if( respond.mediaQueriesSupported ){ } in IE7. I have my CSS with media queries on CDN. Anyone? – Sergei Golubev Commented Feb 10, 2013 at 11:47
  • What's your exact implementation? See the answer to my issue given below. – Alec Rust Commented Feb 18, 2013 at 13:56
Add a ment  | 

1 Answer 1

Reset to default 6

This issue was caused by the respond-proxy.html file reference containing a query string (respond-proxy.html?2013012401). Removing the query string from this file causes the above implementation to work.

发布评论

评论列表(0)

  1. 暂无评论