[英]how to pass url with headers to an img tag (src attribute)
how to pass an url to img tag with headers如何将 url 传递给带有标题的 img 标签
<img src="url" />
I didn't try anything yet, I need some alternative solutions, work should be only javascript in front-end part我还没有尝试任何东西,我需要一些替代解决方案,工作应该只是前端部分的 javascript
If you are talking about the security headers, or any other header of the request then browser will not allow you to do that, as headers are treated as unsafe parameter.如果您正在谈论安全标头或请求的任何其他 header,那么浏览器将不允许您这样做,因为标头被视为不安全参数。 If you need to download an image from the source where validation is required through headers then your option is to send a spearate ajax request with the security headers, there must be a param that allows include current website cookies as header and most probably it will handle the auth part on the server side.
如果您需要从需要通过标头进行验证的源下载图像,那么您的选择是发送带有安全标头的单独 ajax 请求,必须有一个参数允许包含当前网站 cookies 作为 Z099FB995346F339E5E39 并且很可能它将处理服务器端的 auth 部分。 But actually your purpose it not clear, just sentting link with headers to img tag sounds already wrong.
但实际上你的目的并不清楚,只是将带有标题的链接发送到 img 标签听起来已经错了。 If you explain the main purpose maybe we can offer a solution.
如果您解释主要目的,也许我们可以提供解决方案。
PS The same question here have been answered here, if you google 'how to pass url with headers to an img tag' you will see link to stackoverflow as a first result. PS 这里已经回答了同样的问题,如果你用谷歌搜索“如何将带有标题的 url 传递给 img 标签”,你将首先看到指向 stackoverflow 的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.