Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created June 23, 2012 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owainlewis/2979230 to your computer and use it in GitHub Desktop.
Save owainlewis/2979230 to your computer and use it in GitHub Desktop.
Firefox background image rendering bug, jQuery
/*
* I encountered a strange bug with Firefox and dynamic background image updates.
* Background images can't be dynamically updated either through the console or via JavaScript.
* A simple hack is to update the opacity by a very small increment.
* This will force Firefox to re-render the background image correctly.
*/
var rand_opacity = ((0.9 + Math.floor((Math.random()*10)+1))/100);
$(el).css({"background-image":new_image, 'opacity':0.9 + rand_opacity});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment