简体   繁体   中英

JQuery code only working on firefox?

Here's my codepen:

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>

the thing is this only works on my default browser, ie. firefox, it just upright doesnt work on anything else. Any help?

I believe it's because you're loading the typed.js library via GitHub, which doesn't have the correct MIME type. I'd recommend using something like RawGit to serve the library, or just download and load it locally.

Using RawGit the URL would look something like https://rawgit.com/mattboldt/typed.js/master/js/typed.js for development and https://cdn.rawgit.com/mattboldt/typed.js/master/js/typed.js for production.

I've created a JSFiddle you can reference here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM