I have a webgl animation in the background of my site and would like to offer some fallback support for browsers who don't have this feature. I want to serve an image in the background rather than the javascript file which creates the animation.
Modernizr offers some guidance and says to setup an if...else statement to activate the alternative option, like this:
if (Modernizr.webgl) {
// supported
} else {
// not-supported
}
They also suggest this css option:
.no-webgl body { background: red; }
Nether are working.
I don't want to put my animation script in the if statement and then something like this in the else statement:
var oldBrowserFix = document.getElementsByName("body");
oldBrowserFix.style.background = '#ff0000';
I also considered another idea:
do {
var oldBrowserFix = document.getElementsByName("body");
oldBrowserFix.style.background = '#ff0000';
} while (!Modernizr.webgl);
How can I get my do...while statement to work?
Aucun commentaire:
Enregistrer un commentaire