Question

I am new to jquery as in new to try it get worked on IE and Firefox. My script works perfeclty without any trouble whatsoever on Safari, Chrome and Opera, but not on IE and Firefox.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

Here where I think is the problem: I store some strings in localStorage and use them in a fadeIn fadeOut animation. This works in the other browsers but not in FF (the animation is not run repeatedly). When I try just the animation without getting the strings from localStorage, it works in FF, this is why I suspect the problem in the localStorage.

var pro = localStorage.getItem("probes").split(",");
var teststim =  [
        {stim: pro[0],  type: "probe"},
        {stim: pro[1],  type: "probe"},
        {stim: pro[2],  type: "probe"}]
var displayWord = function() {
newword = teststim[Math.floor((Math.random() * teststim.length))];
$("#stimuli").fadeOut(500, function() {
        $("#stimuli").text(newword.stim).fadeIn(10);                    
});    
}
setInterval(displayWord, 2000);
$(document).keypress(function(e) {
  clearInterval(timing);
  displayWord();
  setInterval(displayWord, 2000);
})

This basically takes values from localStorage, uses them in a fade animation, and runs this animation every 2000ms.

Any new ideas? Sorry for the unclear question at first.

Was it helpful?

Solution

Ok. In my case this helped and fixed my problem.

  1. I changed all localStorage to window.localStorage

    window.localStorage.getItem("probes").split(",");

  2. I adjusted a keypress event I have used so that the actual key is coded both in the e.which and e.keyCode way.

    var code = e.keyCode || e.which; (found here)

Maybe someone with the same problem can make use of this.

OTHER TIPS

Does it have to do with how I call jquery?

To answer your question, from the HTML snippet you posted it doesn't seem to have anything to do with that.

jQuery 1.x.x supports IE till older version.

Note: using UTF-8 is recommended over using the latin charset.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

or the shorter HTML5 version

<meta charset="utf-8">

Also, try forcing the latest browser version:

<meta http-equiv="X-UA-Compatible" content="IE=Edge">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top