简体   繁体   English

如何使用javascript打开网址并为请求设置自定义HTTP标头?

[英]How to open a url using javascript and set custom HTTP headers to the request?

I want to redirect a user to a url through javascript after they click on a link. 我想在点击链接后通过javascript将用户重定向到网址。 Now is there any way to send custom http headers along with this request. 现在有没有办法发送自定义http标头以及此请求。 I want to send a particular cookie value with the request headers. 我想使用请求标头发送特定的cookie值。

The url in question does not belong to my domain. 有问题的网址不属于我的域名。

Is it possible to do it? 有可能吗? If yes, how? 如果有,怎么样?

No. 没有。

You can set custom headers if you are using XMLHttpRequest (although it might ban you from setting a Cookie header), but not otherwise (and a redirect is otherwise). 如果您使用的是XMLHttpRequest,则可以设置自定义标头(尽管它可能会禁止您设置Cookie标头),但不会设置(否则会重定向)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM