- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
net。我正在使用 jQuery 执行一些操作。当我将我的代码部署到本地时,它工作正常。但是当我将相同的代码部署到实时服务器时。控制台中出现错误:
Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
请检查我的 html 代码以供引用-:
<html>
<head>
<title>Notifications</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link type="text/css" rel="stylesheet" href="./Content/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="./Content/style.css" />
<script type="text/javascript" src="./Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="./Scripts/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
</head>
<body>
<h2>Send</h2>
<div>
<textarea id="text_message" rows="12" cols="100" placeholder="Please Type Your Message"></textarea>
<div style="margin: 5px">
<input type="button" value="Submit" onclick="sendPush()" />
</div>
<div class="loadermodal" style="display: none">
<div class="center">
<img alt="" src="./Content/img/ajax-loader.gif" />
</div>
</div>
</div>
<script>
function sendMessage() {
var comment = $.trim($("#text_message").val());
if (comment != "") {
// Show alert dialog if value is not blank
// alert(comment);
$(".loadermodal").show();
$.post("/PushNotification/sendPushNotificationToAll", { 'message': comment }).done(function (data) {
var obj = jQuery.parseJSON(data);
if (obj.success != "0") {
alert("Message Sent Successfully");
$(".loadermodal").hide();
}
else
alert("Error in Sending Push");
});
}
else {
alert("Enter Some Text To Send A Message");
}
}
</script>
</body>
在这里,在这段代码中,我创建了一个简单的文本框来编写消息和一个将执行脚本的按钮。这个脚本在我的本地运行良好,但是当我将相同的代码部署到我的应用程序服务器时,这种类型控制台中出现错误。
请分享你对这个问题的看法
谢谢
最佳答案
解决此错误的最简单且更可靠的方法是将源代码从 url 复制到您的 /Scripts/
目录并使用以下方式引用文件:
<script type="text/javascript" src="./Scripts/jquery.csv-0.71.min.js"></script>
看起来您已经在使用 jQuery 和 Bootstrap 文件执行此操作。此方法允许您将存储库中的所有依赖项保持在所需的版本。
除此之外,此错误是为了防止您的网络服务器从您不维护的位置加载潜在的恶意脚本。大多数网络服务器都有允许这样做的设置,但它们最初是禁用的(有充分的理由)。
话虽如此,我仍然建议下载源代码并将其包含在您的项目中。
关于javascript - 拒绝加载脚本 'https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50136589/
我在每个项目中都使用了几个 JavaScript 文件,目前使用 CDNJS 来加载它们。 但是,我想看看是否有一个好的方法来检查 CDN 是否可用,或者文件是否可以从 CDN 获得。当然,如果这些文
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我在我的页面上运行此时间选择器 ( http://timepicker.co/ ) 时遇到问题。 我脑子里有这个 我的脚本中有这个 var hDeb = document.createEleme
cdnjs 和 npm 有什么区别? npm 是一种 CDN(内容分发网络)吗? 最佳答案 npm(节点包管理器)是一个由 Node.js 模块(包)组成的存储库。您可以从中搜索和下载模块。 cdnj
我正在使用大量 CDNJS Javascript 资源,但注意到它们没有并行加载。我可以使用不同的代码提高响应能力吗? 我看过有关域名分片的文章,但找不到替代的 CDNJS 域名,这也可能不是实际的解
对比 (myMin.js 将包含所有连接在一起并缩小的 js 文件)什么是最好的性能?我用的是cdnjs,因为它解决了其他地区的人直接从我的服务器下载js文件的问题。例如,亚洲人不必从
例如:https://cdnjs.com/libraries/jquery Copy按钮位于右侧。它是如何工作的,我如何创建它? 通过检查元素我可以看到该按钮是 Copy ,但我不知道如何找到实际进行
我是 NetBeans 7.4 版本的新手,我一直在搜索如何将 CDNJS 库添加到 NetBeans。当我打开项目属性时,在 JavaScript 文件下没有可用的库。任何方向将不胜感激。 谢谢 最
在我的 HTML 页面中,我想加载以下 CDNjs 但在浏览器中加载如下 获取 http://localhost:8080/cdnjs.cloudflare.com/ajax/libs/tether
我关注 add or update library to cdnjs .我刚刚将 cdnjs 存储库 fork 到我自己的 GitHub 帐户。 在上面的教程中有一行:“当您 fork cdnjs 存
我对此还有另一个问题,但文字很繁琐。我删除了支持这个的其他问题...... 我最近发现了 fullcalendar.js。我最初能够看到日历小部件和 css 样式、标题、导航按钮等。但后来就停止了。我
如何使用Libman作为包管理器和CDNJS作为提供程序将Bootstrap 4库添加到项目中,但似乎不在可用的库列表中? 与Bower&NPM相比,它还有别的名字吗? 在这种情况下,我将Visual
我现在正尝试进入 Asp.Net Core 2.2 MVC。由于来自 DevExpress 日期时间选择器的值,我想使用 moment.js 库进行一些日期计算。我已经能够根据以下内容包含它 inst
我正在努力寻找一个仅从 CDN 运行的最小可运行示例,而不是主要使用本地服务器的现有树内示例。 最佳答案 谷歌搜索后,我发现 https://jsfiddle.net/developit/bwgkr6
我正在使用 UIWebView 在我的 iOS 应用程序中加载网站。更新到 iOS 9 并相应地构建应用程序后,网站仍然可以从我的服务器正常加载,但无法从 cdnjs(例如 https://cdnjs
我这里有 eShopOnContainers 解决方案:https://github.com/dotnet-architecture/eShopOnContainers .在过去的几年里,我一直在积极
我正在尝试关注this因此我将以下代码(从子标题“步骤 2:将 JSX 添加到混合中”下方)直接复制到一个名为 index.html 的文件中,我在 chrome 中打开该文件:
我尝试通过在同一文件夹中创建一个 css 文件 style.css 来做到这一点,复制提供的 bulma 链接的源代码,然后将其链接到我的 html 文档。但是,它根本没有显示任何 css 功能。 最
net。我正在使用 jQuery 执行一些操作。当我将我的代码部署到本地时,它工作正常。但是当我将相同的代码部署到实时服务器时。控制台中出现错误: Refused to load the script
我是一名优秀的程序员,十分优秀!