0

我一直在阅读我能找到的关于这个特定问题的所有帖子,但没有什么能明确解决我的问题。所以,我想我会发布我的具体问题。

在过去的几个月里,我一直在我的网站上运行 tumblr.com/js 提要,但现在它突然坏了。

我在 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 问题和我读过的其他帖子答案之间建立联系。

谢谢!

4

1 回答 1

1

这扩展了我在这里找到的基本答案:mime-type-in​​-chrome

php 文件控制 Content-type,然后使用 readfile() 访问 js 内容。

php:

<?php header("Content-type: text/javascript"); readfile("http://peerlesstree.tumblr.com/js");?>

然后html调用php文件,就好像它是js一样。

html:

<script type="text/javascript" src="js.php"></script>
于 2017-01-03T20:30:51.927 回答