重定向后获取实际的图片网址 [英] Get actual image url after redirect

查看:194
本文介绍了重定向后获取实际的图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Unsplash允许通过以下方式从其网站加载随机图像:

Hi Unsplash allows to load random image from their website via:

https://source.unsplash.com/random/2560x1440

如果每次每次URL生成随机静态图像时我都从浏览器访问URL,例如:

if I access the url from the browser each time the url generates random static image eg:

https://images.unsplash.com/photo-1488616268114-d949a6d72edf?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2560&h=1440&fit=crop&s=a7f66c8417bcf79d2503b84db64c7b1a

我想通过第一个URL在jquery或js中请求图像,并作为响应获取第二个.这可能吗?

I would like to request the image in jquery or js via the first url and in response get the second one. Is this possible?

推荐答案

您可以使用XMLHttpRequest的responseURL.

You can use the responseURL of the XMLHttpRequest.

MDN参考

此答案,以jQuery和本机JS为例.

and this answer for an example in jQuery and native JS.

这篇关于重定向后获取实际的图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆