Created
February 15, 2012 19:52
-
-
Save mavenlink/1838523 to your computer and use it in GitHub Desktop.
Fix Chrome background refresh bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function refreshBackgrounds(selector) { | |
// Chrome shim to fix http://groups.google.com/a/chromium.org/group/chromium-bugs/browse_thread/thread/1b6a86d6d4cb8b04/739e937fa945a921 | |
// Remove this once Chrome fixes its bug. | |
if (/chrome/.test(navigator.userAgent.toLowerCase())) { | |
$(selector).each(function() { | |
var $this = $(this); | |
if ($this.css("background-image")) { | |
var oldBackgroundImage = $this.css("background-image"); | |
setTimeout(function() { | |
$this.css("background-image", oldBackgroundImage); | |
}, 1); | |
} | |
}); | |
} | |
} | |
// You'll need to call this every time the event occurs that exposes the bug, such as changing tab divs. | |
refreshBackgrounds(".something-with-a-background-image"); | |
refreshBackgrounds("*"); // but it'll be slow! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment