2016-05-31 181 views
0

这里是我的codepen:JQuery代码只适用于Firefox?

http://codepen.io/anon/pen/gMbaMW

<!DOCTYPE html> 
<html> 
<head> 
<title>About me</title> 

<link rel="stylesheet" type="text/css" href="css/aboutme.css"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
<script src="https://raw.githubusercontent.com/mattboldt/typed.js/master/js/typed.js"></script> 


<script> 

    $(function(){ 
     $("#typed").typed({ 
      strings: ["Jack.", "a Programmer.","a Gamer.","an Enthusiast who has a passion for Knowledge, Experiences, Challenges and Food."], 
     typeSpeed: 20, 
      loop: false, 
      // defaults to false for infinite loop 
      callback: function(){ foo(); } 
     }); 


     function foo(){ console.log("Callback"); } 
    }); 

</script> 

</head> 

<header> 
<p>So, who am I?</p> 
</header> 
<body> 
<div class ="mtext"> 
<h1 id="pretyped"> I am <h1 id="typed"></h1></h1> 

<br> 
</div> 

</body> 
</html> 

的事情是我的默认浏览器,也就是说这仅适用。火狐,它只是直立不适用于其他任何东西。任何帮助?

回答

0

我相信这是因为你正在通过GitHub加载typed.js库,它没有正确的MIME类型。我建议使用类似RawGit的东西来为图书馆服务,或者只是在本地下载并加载它。

使用RawGit的URL看起来像https://rawgit.com/mattboldt/typed.js/master/js/typed.js开发和https://cdn.rawgit.com/mattboldt/typed.js/master/js/typed.js生产。

我创建了一个JSFiddle,你可以参考here

+0

omfg,非常感谢你的原始链接修复它。你最好的<3 –

相关问题