为什么我可以'不要在任何主机上使用javascript(PC除外)
Why I can't use javascript any hosting (Except PC)
我有这个源代码:
<!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>
我在电脑上对表格进行排序可以很好地工作,但当我把这个HTML文件上传到主机时,排序表格就不起作用了。主机会为我禁用Javascript吗?
我用GoogleDrive做主机。我试过Dropbox,但它也不起作用。
示例表:https://2cdf7d8230e2b51a89d897a354b906bcb02dfca8.googledrive.com/host/0B_WPAWweGO9mfnpGM1FNR0pLZ1VEQlJHQzNJMGRrd3hwaW9WTjg0aE91MG1uZkhCQzJWRzQ/heroes-data.html
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 Drive网站在HTTPS下运行,但请求的javascript是通过HTTP链接的。你需要匹配协议,否则浏览器会变得可疑并阻止链接的脚本。
我假设Google Drive文件必须通过HTTPS提供,所以你不能改变这一点。但您可以更改的是链接脚本的协议。
<script type="text/javascript" src="//community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>
我从src URL中删除了http:
,因此它是"无协议的",并将适应于当前文档中的任何内容,在本例中为HTTPS。现在它应该匹配并正确加载。你也很幸运,提供文件的网站能够通过HTTPS提供服务(他们有SSL证书)。
您应该在浏览器控制台中看到此错误:
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/sortable.js
尝试这个
<!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>
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 使用php或javascript从facebook相册URL中删除多余的部分
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在JavaScript中将字符串转换为函数引用
- 模糊事件的Javascript测试
- 在Javascript中计算两个日期之间的工作日,节假日除外
- 我的javascript适用于所有浏览器,但IE8除外
- JavaScript中的简单正则表达式适用于所有浏览器,但Safari除外
- 为什么我可以'不要在任何主机上使用javascript(PC除外)
- 使用 javascript 重写特定链接,但指向特定目录的链接除外
- JavaScript 生成随机数,但某些值除外
- 在JavaScript中检查null可以正常工作,但零除外
- Javascript Regex-替换匹配字符串的所有出现,括号之间的任何字符串除外
- 在javascript中显示未来5天(星期日除外)
- Javascript:用逗号分割字符串,括号内除外
- PHP字符串在javascript代码中加上逗号,最后一个字符串除外
- Rails javascript文件(application.js除外)无法工作
- 不能从iframe访问浏览器平板电脑(Firefox除外)中的父javascript