To make our user interface more shiny we recently decided to use animated gifs in a couple of places. Especially when using ajax to reload some areas of the page we want to show a spinning wheel wait. For the user it feels more like something is going on (something is beeing processed) instead of having some kind of frozen screen. But with Internet Explorer it is not done with just placing an animated gif in the page. IE stops animating the gif in a couple of scenarios. Here you can see some hacks to convince IE to animated the gifs again: >> more…

We use the javascript window.setTimeout method for a recursive call of a function with certain parameters. Because the function call has to be constructed by string concatenation, we have to escape potential quotes inside the parameters. After some regex headache we came up with the following generic solution:

function escapeQuotes(value) {
   value = value.replace(/([^\\])'|^'/g, "$1\\'");
   return value.replace(/([^\\])"|^"/g, "$1\\\"");
}

Feel free to use it or simply test your regex reading capabilities.