当我尝试将本地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) 我问了一个关于从GitHub中包含资源的问题,答案是使用原始链接:
https://raw.github.com/username/repository/branch/file.js
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下内容包含脚本:
<script
type="text/javascript"
src="https://raw.github.com/username/repo/master/src/file.js"
></script>
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
拒绝执行' https://raw.github.com/username/repo/master/src/file.js '中的脚本,因为它的MIME类型('text/plain')不可执行,并且启用了严格的MIME类型检查.
有没有其他方法可以解决此错误?
我不是在制作中使用它而是用于演示页面:
project-repository-from-github
?? master
? ?? src
? ? ?? my-jQuery-plugin.js
? ?? README.md
?? gh-pages
?? css
? ?? style.css
?? index.html
Run Code Online (Sandbox Code Playgroud)
在index.html页面中,我想拥有my-jQuery-plugin.js的最新版本.所以,我会将原始URL包含在脚本中.
我该如何修复错误?
我正在构建一个代码块,并遇到了一个问题,这使我很好奇为什么为什么&符不会从WordPress文本编辑器视图进行编码。这段代码按预期工作,当通过文本编辑器直接嵌入到页面中时,它会向我发出警报:
// This code works as expected
<script>
jQuery(document).ready(function() {
if (jQuery('select[name=idx-q-PropertyTypes]:first').val()=='') {alert ('it exists');} else {alert ('cant find it');}
jQuery('.dsidx-resp-area-submit input').click(function(e){
alert ("you clicked it");
if (jQuery('select[name=idx-q-PropertyTypes]:first').val()=='') {
alert ('There were no search parameters.');
e.preventDefault();
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我想做的下一件事是检查条件并发。所以我将代码更改为此:
// This code gives errors
<script>
jQuery(document).ready(function() {
if (jQuery('select[name=idx-q-PropertyTypes]:first').val()=='') {alert ('it exists');} else {alert ('cant find it');}
jQuery('.dsidx-resp-area-submit input').click(function(e){
alert ("you clicked it");
if (
jQuery('select[name=idx-q-PropertyTypes]:first').val()=='' &&
jQuery('select[name=idx-q-Cities]:first').val()=='' &&
jQuery('input[name=idx-q-PriceMin]:first').val()=='' &&
jQuery('input[name=idx-q-PriceMax]:first').val()=='' &&
jQuery('select[name=idx-q-BedsMin]:first').val()=='' &&
jQuery('select[name=idx-q-BathsMin]:first').val()=='' &&
jQuery('input[name=idx-q-ImprovedSqFtMin]:first').val()=='' …Run Code Online (Sandbox Code Playgroud) 我把它添加到我的WordPress 页面
if (script.readyState && script.onload!==null){
script.onreadystatechange= function () {
if (this.readyState == 'complete') mce_preload_check();
}
}
Run Code Online (Sandbox Code Playgroud)
和&&正在被关到
if (script.readyState && script.onload!==null){
Run Code Online (Sandbox Code Playgroud)
我在WordPress HTML视图中粘贴了这个,我确定这很好,但WordPress一直在显示它.怎么解决这个问题?