我使用以下代码打印 div 元素内的内容。在我在服务器中安装 SSL 证书之前,这对我来说效果很好。如果我通过 http://
访问页面,代码仍然有效。但是,当通过 https://
访问同一页面时,它不起作用。我需要帮助解决这个问题。
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;
}
注意:当我使用firebug诊断错误时,它显示错误“$ is not a function”。类似的其他脚本也面临同样的问题。
最佳答案
Note: When I used firebug to diagnose the bug, it showed the error "$ is not a function". Similar other scripts are facing the same problem.
您很可能是从 HTTP URL(也许是 CDN?)加载 jQuery,这会导致浏览器以不安全为由阻止它。所有 Assets - 图片、脚本、CSS 等 - 都需要在 HTTPS 页面上使用 HTTPS。
关于javascript - 安装 SSL 后某些脚本停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17886650/