Javascript 和 jQuery 通过 https 不安全
我正在构建一个将在 Azure 中运行的 ASP.NET MVC 3 应用程序。一切都运行良好,直到我切换到 https。现在我的大多数 jQuery 插件和其他一些 javascript 都不安全。
我正在使用 Datatables 库以及 jsTree、Watermaks 和 Breadcrumbs。该脚本的大部分内容是为了让我们的网站看起来有吸引力。
有没有办法保证这个安全?或者是时候迁移一个非常精简的 javascript 站点了?
谢谢您的帮助!
I am building an ASP.NET MVC 3 app which will run in Azure. Everything was working well, until I switched to https. Now most of my jQuery plugins and some other javascript are not secure.
I'm using the Datatables library as well as jsTree, Watermaks and Breadcrumbs. Most of this script is to make our site look appealing.
Is there a way to make this secure? Or is it time to move a very lean javascript site?
Thank you for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 站点本身不支持 https:// 作为主机。我的建议是下载最新版本并使用相对路径(例如
/js/jquery.js
)自行托管,以便它与您的协议匹配。附带说明一下,从绝对路径开头删除协议将与用户正在浏览的协议相匹配。如下所示:将链接到 http 或 https,具体取决于用户正在浏览的当前 url。
The jQuery site itself does not support https:// as a host. My suggestion is to download the latest version and host it yourself with a relative path (eg.
/js/jquery.js
) so it will match your protocol. As a side note, removing the protocol from the beginning of an absolute path will match the protocol that the user is browsing in. Like so:<script src="//www.google.com/someresource.js"></script>
will link to either http or https depending on the current url the user is browsing.
只需通过
https
而不是http
加载脚本......似乎很明显。如果您从 CDN 加载它们,请检查该 CDN 是否有
https
选项,如果没有,您需要通过与您相同的https
协议自行提供服务用于网站的其余部分。Just load your scripts via
https
instead ofhttp
... seems obvious enough.If you are loading them from a CDN, check if said cdn has a
https
option, if not, you'll need to serve them yourself through the samehttps
protocol you are using for the rest of your site.