且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么在HTML中使用href =“"//代替href ="http://?

更新时间:2022-04-04 23:31:03

是的,它将使用当前协议.

Yes, it will use the current protocol.

即如果当前页面为https,它将使用https访问href.

i.e. if the current page is https it will access the href using https.

如果为http,则可以通过普通的http访问该链接.

If http then the link is accessed over plain http.

如果托管页面为https,它将防止浏览器警告,并且比普通的http链接更加安全.

This will prevent browser warnings if the hosting page is https and will be more secure than a plain http link.