相关疑难解决方法(0)

链接并执行GitHub上托管的外部JavaScript文件

当我尝试将本地JavaScript文件的链接引用更改为GitHub原始版本时,我的测试文件停止工作.错误是:

拒绝从...执行脚本,因为它的MIME类型(text/plain)不可执行,并且启用了严格的MIME类型检查.

有没有办法禁用此行为或是否有允许链接到GitHub原始文件的服务?

工作代码:

<script src="bootstrap-wysiwyg.js"></script>
Run Code Online (Sandbox Code Playgroud)

非工作代码:

<script src="https://raw.github.com/mindmup/bootstrap-wysiwyg/master/bootstrap-wysiwyg.js"></script>
Run Code Online (Sandbox Code Playgroud)

javascript github

525
推荐指数
8
解决办法
15万
查看次数

什么是"X-Content-Type-Options = nosniff"?

我正在使用OWASP ZAP对我的localhost进行一些渗透测试,并且它会不断报告此消息:

Anti-MIME-Sniffing标头X-Content-Type-Options未设置为'nosniff'

此检查特定于Internet Explorer 8和Google Chrome.如果Content-Type标头未知,请确保每个页面设置Content-Type标头和X-CONTENT-TYPE-OPTIONS

我不知道这意味着什么,我在网上找不到任何东西.我试过添加:

<meta content="text/html; charset=UTF-8; X-Content-Type-Options=nosniff" http-equiv="Content-Type" />
Run Code Online (Sandbox Code Playgroud)

但我仍然得到警报.

设置参数的正确方法是什么?

html meta owasp http-headers penetration-testing

256
推荐指数
5
解决办法
29万
查看次数

由于MIME类型错误,Chrome拒绝执行AJAX脚本

我试图通过AJAX将脚本作为JSON访问,这在Safari和其他浏览器上运行良好但不幸的是不能在Chrome中执行.它出现以下错误:

拒绝从'*'执行脚本,因为它的MIME类型('application/json')不可执行,并且启用了严格的MIME类型检查.

这是请求:

$.ajax({
    url: "http://some_url/test.json?callback=?",
    type: "GET",
    dataType: 'json',
    cache: true,
    success: function (data, status, error) {
      console.log('success', data);
    },
    error: function (data, status, error) {
      console.log('error', data, status, error);
    }
});
Run Code Online (Sandbox Code Playgroud)

有人有解决方法吗?

javascript ajax jquery json google-chrome

142
推荐指数
3
解决办法
29万
查看次数

在本地dev上禁用chrome strict MIME类型检查

我有一个CSS文件,我的本地开发服务器(webpack)提供的服务显然是错误的mime类型.

Refused to apply style from 'http://localhost:10001/font-awesome/css/font-awesome.min.css' 
because its MIME type ('text/html') is not a supported stylesheet MIME type, 
and strict MIME checking is enabled.
Run Code Online (Sandbox Code Playgroud)

反正有禁用此功能吗?我认为这是一个镀铬设置.至少对于特定的主机.

深入研究webpack配置,如果它不做这样基本的事情通常是令人沮丧的牦牛剃须练习.

大多数其他答案指的是修复服务器的方法.我只是想破解这个客户端,因为服务器很顽固.

有关:

google-chrome mime-types webpack

9
推荐指数
1
解决办法
5208
查看次数

如何将我的 CSS 链接到 github 托管站点中的 HTML

我的问题是,我尝试使用 Github 页面托管的网站不会读取我链接到它的 CSS。

我的 HTML 看起来像这样:

<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="https://github.com/legoman8304/legoman8304.github.io/blob/master/style.css">
<html>
    <body>
        <h1>Hello World</h1>
        <p>I'm under construction!</p>
        <h6>Copyright MIT Licence 2018</h6>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的 CSS 看起来像这样:

body {
  background-color: lightblue;
}

h6 {
  color: navy;
  margin-left: 20px;
}
Run Code Online (Sandbox Code Playgroud)

链接存储库:legoman8304.github.io

我猜我链接的 CSS 是错误的,因为当我在网站本身上使用检查元素时,它确实显示,style.css但打开时它是空的。有什么帮助吗?

html css hosting github github-pages

4
推荐指数
1
解决办法
2万
查看次数