添加ssl證書后https訪問無js,css處理辦法
代碼中引用所致
主頁面用https,相關(guān)的資源也要用https的,否則瀏覽器會(huì)拒絕加載這些資源
請將css和js都用https
在https的網(wǎng)站中引用http路徑的js或css會(huì)導(dǎo)致不起作用,其形如:
<script src="http://www.tjdsmy.cn/jquery-1.11.0.min.js"></script>1
解決辦法:
將http:去掉,改為
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
常見模板例子:
wordpress
找到functions.php
添加如下代碼:
add_filter('script_loader_src', 'agnostic_script_loader_src', 20,2); function agnostic_script_loader_src($src, $handle) {return preg_replace('/^(http|https):/', '', $src); } add_filter('style_loader_src', 'agnostic_style_loader_src', 20,2); function agnostic_style_loader_src($src, $handle) {return preg_replace('/^(http|https):/', '', $src); }