我有这个源代码:
<!DOCTYPE html>
<head>
<script type="text/javascript" src="http://community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>
<style type="text/css">
th, td {
padding: 3px !important;
}
table.sortable thead {
background-color:#eee;
color:#666666;
font-weight: bold;
cursor: default;
}
</style>
</head>
<body>
<table class="sortable">
<thead>
<tr>
<td><strong>Name</strong></td>
<td><strong>Salary</strong></td>
<td><strong>Extension</strong></td>
<td><strong>Start Date</strong></td>
<td><strong>Start Date(American)</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td>Bloggs, Fred</td>
<td>$12000.00</td>
<td>1353</td>
<td>18/08/2003</td>
<td>08/18/2003</td>
</tr>
<tr>
<td>Shakespeare, Hamnet</td>
<td>$9000</td>
<td>9005</td>
<td>01/01/2002</td>
<td>01/01/2002</td>
</tr>
<tr>
<td>Mbogo, Arnold</td>
<td>$32010.12</td>
<td>2755</td>
<td>09/08/1998</td>
<td>08/09/1998</td>
</tr>
<tr>
<td>Fitz, Marvin</td>
<td>$3300</td>
<td>5554</td>
<td>22/05/1995</td>
<td>05/22/1995</td>
</tr>
<tr>
<td>Turvey, Kevin</td>
<td>$191200.00</td>
<td>2342</td>
<td>02/05/1979</td>
<td>05/02/1979</td>
</tr>
<tr>
<td>Shakespeare, Bill</td>
<td>$122000.00</td>
<td>3211</td>
<td>12/11/1961</td>
<td>11/12/1961</td>
</tr>
</tbody>
<tfoot>
<tr>
<td><strong>TOTAL</strong></td>
<td>$369510</td>
<td></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>
我通过对表进行排序在PC上正常工作,但是当我将此HTML文件上传到我的主机时,排序表不起作用。主持人可以为我禁用Javascript吗?
我使用GoogleDrive来托管。我试过Dropbox,但它也不起作用。
答案 0 :(得分:1)
您应该在浏览器控制台中看到此错误:
Mixed Content: The page at 'https://2cdf7d8230e2b51a89d897a354b906bcb02dfca8.googledrive.com/host/0B_WP…pGM1FNR0pLZ1VEQlJHQzNJMGRrd3hwaW9WTjg0aE91MG1uZkhCQzJWRzQ/heroes-data.html' was loaded over HTTPS, but requested an insecure script 'http://community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js'. This request has been blocked; the content must be served over HTTPS.
这意味着您使用的js库使用http调用,而html页面使用https调用。 您只需要更改库URL方案:https://community.wdfiles.com/local--files/howto%3Asortable-tables-js/sorttable.js
答案 1 :(得分:1)
Chrome报告:
Mixed Content: The page at 'https://2cdf7d8230e2b51a89d897a354b906bcb02dfca8.googledrive.com/host/0B_WP…pGM1FNR0pLZ1VEQlJHQzNJMGRrd3hwaW9WTjg0aE91MG1uZkhCQzJWRzQ/heroes-data.html' was loaded over HTTPS, but requested an insecure script 'http://community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js'. This request has been blocked; the content must be served over HTTPS.
总结:This request has been blocked; the content must be served over HTTPS.
您的Google云端硬盘网站在HTTPS下运行,但请求的JavaScript通过HTTP进行链接。您需要匹配协议,否则浏览器会产生怀疑并阻止链接的脚本。
我将假设必须通过HTTPS提供Google云端硬盘文件,因此您无法对其进行更改。但是你可以改变的是链接脚本的协议。
<script type="text/javascript" src="//community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>
我从src网址中删除了http:
,因此它是无协议的&#39;并将适应当前文档的任何内容,在这种情况下为HTTPS。现在它应该匹配并正确加载。您也很幸运,提供该文件的网站能够通过HTTPS提供服务(他们拥有SSL证书)。
答案 2 :(得分:1)
试试这个
<!DOCTYPE html>
<head>
<script type="text/javascript" src="//community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>
<style type="text/css">
th, td {
padding: 3px !important;
}
table.sortable thead {
background-color:#eee;
color:#666666;
font-weight: bold;
cursor: default;
}
</style>
</head>
<body>
<table class="sortable">
<thead>
<tr>
<td><strong>Name</strong></td>
<td><strong>Salary</strong></td>
<td><strong>Extension</strong></td>
<td><strong>Start Date</strong></td>
<td><strong>Start Date(American)</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td>Bloggs, Fred</td>
<td>$12000.00</td>
<td>1353</td>
<td>18/08/2003</td>
<td>08/18/2003</td>
</tr>
<tr>
<td>Shakespeare, Hamnet</td>
<td>$9000</td>
<td>9005</td>
<td>01/01/2002</td>
<td>01/01/2002</td>
</tr>
<tr>
<td>Mbogo, Arnold</td>
<td>$32010.12</td>
<td>2755</td>
<td>09/08/1998</td>
<td>08/09/1998</td>
</tr>
<tr>
<td>Fitz, Marvin</td>
<td>$3300</td>
<td>5554</td>
<td>22/05/1995</td>
<td>05/22/1995</td>
</tr>
<tr>
<td>Turvey, Kevin</td>
<td>$191200.00</td>
<td>2342</td>
<td>02/05/1979</td>
<td>05/02/1979</td>
</tr>
<tr>
<td>Shakespeare, Bill</td>
<td>$122000.00</td>
<td>3211</td>
<td>12/11/1961</td>
<td>11/12/1961</td>
</tr>
</tbody>
<tfoot>
<tr>
<td><strong>TOTAL</strong></td>
<td>$369510</td>
<td></td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</body>
</html>