protocol意義

1

var _bdhmProtocol =
 (("https:" == document.location.protocol) ? " https://" : " http://");

document.write(unescape("%3Cscript src='" + _bdhmProtocol +"hm.baidu.com/h.js%3F7bb9f12e5e3beab67267db2e
094585f1' type='text/javascript'%3E%3C/script%3E"));

參考博客:https://blog.csdn.net/gui951753/article/details/82227800
點這裏進入
總結:首先protocol返回當前URL協議,當前URL如果等於https則返回https://,若不等於,則返回http://,這是爲了方便用戶查找到該網站。之後寫的東西我目前也不知道,只知道unescape會將字符串中的%全部換爲\。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章