通过https链接到jQuery [英] Linking to jquery via https

查看:477
本文介绍了通过https链接到jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个登录页面,这是一个新的内容,刚开始仅使用http进行构建.一切工作都以我期望的方式进行.现在,我试图严格通过https限制访问.在我的html头中,我目前有:

I'm developing a login page, and being new, started off building just using http. Everything is working the way I expect to this point. Now I'm trying to limit access strictly via https. In my html head, I currently have:

<script type="text/javascript" src="/localhost/js/jquery-2.0.2.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

但是,通过https访问时,由于内容不安全,导致jquery-ui.js的链接被阻止.我可以将链接更改为 https://code.jquery.com/ui /1.10.3/jquery-ui.js ,但随后在jquery-2.0.2.js的第8268行上出现未捕获的TypeError:对象#的属性'#'不是函数.".如果我下载jquery-ui.js文件并在本地链接到该文件,则所有内容都可以使用http和https.但是,为什么在外部托管时它不起作用?有人可以解释为什么会发生这种情况以及我可以采取什么措施来解决吗?在本地托管链接文件还是在外部托管链接文件是否有好处/缺点?预先谢谢你!

However, when accessed via https, the link to jquery-ui.js gets blocked due to being insecure content. I can change the link to https://code.jquery.com/ui/1.10.3/jquery-ui.js, but then I get an "Uncaught TypeError: Property '#' of object # is not a function.", on line 8268 of jquery-2.0.2.js. If I download the jquery-ui.js file and link to it locally, everything works http and https. But why does it not work when hosted externally? Can someone explain why this is happening and what I can do to resolve it? Is there a benefit/drawback to hosting linked files locally versus externally? Thank you in advance!

推荐答案

最简单的解决方案是下载jquery ui并在服务器(本地主机)上包含该版本.这样,您发送给Google的数据就更少了.

The easiest solution would be to download jquery ui and include the version on your server (localhost). This way you send less data to google.

从外部托管它的好处是该文件可能已经被缓存,因为用户之前访问过包含该文件的另一个页面,因此可以提高首页的速度.

the benefit of hosting it externally is that the file might be already cached, because the user visited another page including it before, so it could improve the speed of your homepage.

它仅与https://code.jquery.com不兼容,因为code.jquery.com不支持ssl.

it just doesn't work with https://code.jquery.com because code.jquery.com does not support ssl.

这篇关于通过https链接到jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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