如何在源代码中使用 JavaScript 将每个 http 更改为 https?
我想使用 JavaScript 将每个 http 实例更改为 https。我该怎么做?源代码会是什么样子?
I would like to change every instance of http to https using JavaScript. How can I do this? what would the source code look like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不管怎样,我假设你所追求的是标签,但应该很容易将其推断到其他人:
Anyway, I assume what you are after is in tags, but it should be easy to extrapolate this to others:
您可以向http域页面中的servlet抛出https更改请求,服务器将重定向到https域页面。尝试在 javascript 中将域从 http 更改为 https 将导致浏览器安全错误(因为所有现代浏览器都拒绝跨域请求)。
我解决了同样的问题,如下所示。
你可以参考这里。 参考页面。
You can throw https change request to servlet in http domain page, and server will redirect to https domain page. Trying to change domain from http to https in javascript will cause browser security error(as cross domain requests are denied in all modern browsers).
I solved the same problem as shown below.
you can refer here. refer page.
您可以在 JavaScript 中将 http 流量重定向到 https,如下所示:
You can redirect http traffic to https in JavaScript with something like: