Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我能';不要在任何主机上使用javascript(PC除外)_Javascript_Html - Fatal编程技术网

为什么我能';不要在任何主机上使用javascript(PC除外)

为什么我能';不要在任何主机上使用javascript(PC除外),javascript,html,Javascript,Html,我有以下源代码: <!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 !impo

我有以下源代码:

<!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>

th,td{
填充:3px!重要;
}
table.sortable thead{
背景色:#eee;
颜色:#666666;
字体大小:粗体;
游标:默认值;
}
名称
工资
扩展
开始日期
开始日期(美国)
布洛格斯,弗雷德
$12000.00
1353
18/08/2003
08/18/2003
莎士比亚,哈姆内特
$9000
9005
01/01/2002
01/01/2002
姆博戈,阿诺德
$32010.12
2755
09/08/1998
08/09/1998
菲茨,马文
$3300
5554
22/05/1995
05/22/1995
特维,凯文
$191200.00
2342
02/05/1979
05/02/1979
莎士比亚,比尔
$122000.00
3211
12/11/1961
11/12/1961
总计
$369510
我可以在PC上对表格进行排序,但是当我将这个HTML文件上传到主机时,排序表格就不起作用了。主机是否可以为我禁用Javascript

我用谷歌硬盘来主持。我试过Dropbox,但也不起作用


示例表:

您应该在浏览器控制台中看到此错误:

 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方案:

Chrome reports:

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.
总之:
此请求已被阻止;内容必须通过HTTPS提供。

您的Google Drive网站正在HTTPS下运行,但请求的javascript正在通过HTTP链接。您需要匹配协议,否则浏览器将变得可疑并阻止链接的脚本

<script type="text/javascript" src="//community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>
我假设谷歌硬盘文件必须通过HTTPS提供,所以你不能改变这一点。但您可以更改的是链接脚本的协议

<script type="text/javascript" src="//community.wikidot.com/local--files/howto:sortable-tables-js/sorttable.js"></script>

我从src URL中删除了
http:
,因此它是“无协议的”,并且将适应当前文档中提供的内容,在本例中是HTTPS。现在,它应该匹配并正确加载。您还很幸运,为文件提供服务的站点能够通过HTTPS提供服务(他们有SSL证书)。

试试这个

<!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>

th,td{
填充:3px!重要;
}
table.sortable thead{
背景色:#eee;
颜色:#666666;
字体大小:粗体;
游标:默认值;
}
名称
工资
扩展
开始日期
开始日期(美国)
布洛格斯,弗雷德
$12000.00
1353
18/08/2003
08/18/2003
莎士比亚,哈姆内特
$9000
9005
01/01/2002
01/01/2002
姆博戈,阿诺德
$32010.12
2755
09/08/1998
08/09/1998
菲茨,马文
$3300
5554
22/05/1995
05/22/1995
特维,凯文
$191200.00
2342
02/05/1979
05/02/1979
莎士比亚,比尔
$122000.00
3211
12/11/1961
11/12/1961
总计
$369510