https頁面 和 http請求的問題

(1)強制升級http 靜態資源地址爲https地址

https頁面中不能使用http請求,http頁面中可使用https請求。php

關於在https 頁面有一些http的請求,能夠在<head></head>中設置ajax

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

來自動升級http到https,就不須要修改源代碼了。瀏覽器

 若是有些瀏覽器不支持,能夠設置jsp

phpui

header("Content-Security-Policy: upgrade-insecure-requests");

jspspa

如jsp頁面<head></head>標籤中能夠這樣設置code

<%response.setHeader("Content-Security-Policy","upgrade-insecure-requests");%>

注意:只針對靜態資源 如<script src="">  ,<img src="">,  <link href="" rel="stylesheet"> , <iframe src=""></iframe> ,  ajax請求 ,等blog

對於<a href="">  <script> window.location.href=""</script>不起做用ip

(2) https 頁面超連接,及iframe 地址爲http的問題

https頁面能夠直接跳轉到 http頁面。資源

若是一個https頁面中包含一個iframe,則此iframe的src不能爲http地址

若是一個 https頁面加載的一個iframe 頁面中,包含一個http超連接,則此超連接必須加上 target="_blank",此時會在新的頁面打開。若是target="_self"則不會跳轉。

(3)https頁面中不能使用http的ajax地址, 

 可使用(1)中代碼自動升級http到https

相關文章
相關標籤/搜索