我一直在阅读我能找到的有关此特定问题的所有帖子,但没有任何内容明确解决我的问题。因此,我想我应该发布有关我的具体问题的文章。
过去几个月我一直在我的网站上运行 tumblr.com/js feed,但现在它突然崩溃了。
我在 Chrome 中遇到(看似常见的)错误:
Refused to execute script from 'http://peerlesstree.tumblr.com/js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
就在几个月前,它成功地将 tumblr 内容导入到带有简单 html 标签的 div 中:
<div class="tumblrposts">
<script type="text/javascript" src="http://peerlesstree.tumblr.com/js"></script>
</div>
我不知道为什么它突然停止工作,并且似乎无法找到此问题的具体解决方案。我看过一些帖子将人们引向 mime 类型的设置,但我还没有能够实现一个来实现这项工作。
我并不是想重复这些其他 chrome mime 类型错误问题,我只是无法将我的特定 tumblr/js 问题与我读过的其他帖子答案联系起来。
谢谢!
最佳答案
这扩展了我在这里找到的基本答案:mime-type-in-chrome
php文件控制Content-type,然后使用readfile()访问js内容。
php:
<?php header("Content-type: text/javascript"); readfile("http://peerlesstree.tumblr.com/js");?>
然后html像调用js一样调用php文件。
html:
<script type="text/javascript" src="js.php"></script>
关于javascript - Tumblr js 输出 MIME 类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41134898/