How do I listen to 301/302 redirect status codes on multi-domain image requests?

I have a few
‘s that are linked (with the src
attribute) to cross-domain URLS that may need to redirect to some other image URL. I need to somehow track every redirect that takes place when the browser requests the original URL.

So for example, If I have:

and http://www.something.com/redirect
sent a custom location
header to http://something.com/pic.jpg
, I need to know about it. How could I detect a redirect in JS or jQuery on a
?

If you’re not constrained to IE7 you could use a cors solution. That will let you request cross-domain without the limitations of JSON-P (i.e. you can get status codes).

See https://developer.mozilla.org/en/http_access_control
for more information. For a simple GET request you should be fine, but if you need to POST then you may need to preflight your request.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » How do I listen to 301/302 redirect status codes on multi-domain image requests?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录