如何使用javascript打开网址并为请求设置自定义HTTP标头? [英] How to open a url using javascript and set custom HTTP headers to the request?

查看:1232
本文介绍了如何使用javascript打开网址并为请求设置自定义HTTP标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户点击链接后通过javascript将用户重定向到网址。现在有任何方式发送自定义http头以及这个请求。我想向请求标头发送特定的Cookie值。



相关网址不属于我的网域。



有可能吗?如果是,如何?



您可以设置您的帐户。

解决方案

如果您使用XMLHttpRequest(虽然它可能会禁止您设置 Cookie 头),但不是其他(否则重定向)。


I want to redirect a user to a url through javascript after they click on a link. Now is there any way to send custom http headers along with this request. I want to send a particular cookie value with the request headers.

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).

这篇关于如何使用javascript打开网址并为请求设置自定义HTTP标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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