2013-07-26 67 views
0

我使用以下代碼打印div元素內的內容。直到我在服務器中安裝了SSL證書之前,這對我來說工作得很好。如果我通過http://訪問該頁面,該代碼仍然有效。但是,當通過https://訪問相同的頁面時,它不起作用。我需要幫助解決這個問題。某些腳本在安裝SSL後停止工作

function PrintElem(elem) 
{ 
    Popup($(elem).html()); 
} 

function Popup(data) 
{ 
    var mywindow = window.open('', 'Business Sense Chart', 'height=600,width=1200'); 
    mywindow.document.write('<html><head><title>Business Sense Analytics</title>'); 
    mywindow.document.write('<link rel="stylesheet" href="./css/style.css" type="text/css" />'); 
    mywindow.document.write('</head><body><center>'); 
    mywindow.document.write(data); 
    mywindow.document.write('</center></body></html>'); 
    mywindow.print(); 
    return true; 
} 

注意:當我用螢火蟲來診斷錯誤,它顯示錯誤「$不是一個函數」。類似的其他腳本也面臨同樣的問題。

+3

你可能包括腳本使用'http'鏈接(而不是'https')。瀏覽器默認阻止非安全內容。 – Halcyon

回答

4

注意:當我使用firebug來診斷錯誤時,它顯示錯誤「$不是函數」。類似的其他腳本也面臨同樣的問題。

您很可能將jQuery從HTTP URL(可能是?)中加載,這會導致瀏覽器將其阻塞爲不安全。所有資產 - 圖像,腳本,CSS等 - 需要在HTTPS頁面上使用HTTPS。

+0

我使用HTTPS來包含jQuery和其他東西。 – wishchaser

+0

'$不是函數'意味着jQuery沒有加載,或者在jQuery被包含之前用jQuery做東西。檢查Firebug並確保jQuery的HTTPS請求正在工作。 – ceejayoz

+0

好的。將再次檢查並回傳。 – wishchaser

相關問題