I have some WebGL stuff in an iframe. On some web browsers or old computers, the iframe isn't loading. When this happens I'd like to load an image instead. Is it possible and if yes how to do it ?
Thanks
I have some WebGL stuff in an iframe. On some web browsers or old computers, the iframe isn't loading. When this happens I'd like to load an image instead. Is it possible and if yes how to do it ?
Thanks
Wether or not WebGL is supported is probably best checked the same way you do in Javascript
WebGLRenderingContext gl = canvas.getContext("experimental-webgl")
if(!gl)
{
$("#image").show()
}
<script>
:First of all it seems that you have some problems within your <script>
tag. There is plain <center><iframe ...
HTML tags inside <script>
tag which does not work as there should be only javascript here. There is also some missing ;
semicolons.
You could try this one but I also recommend checking out linked sites at end of my answer:
?>
<script type="text/javascript">
if (!window.WebGLRenderingContext) {
var myImage = new Image();
myImage.src = "http://domain.tld/picture.jpg";
$(myImage).prependTo(document.body);
} else {
$(document.body).prepend('<center><iframe ALLOWTRANSPARENCY="true" frameborder="0" height="340" width="454" src="CORRECT THIS FIELD"></iframe></center>');
}
</script>
<?php
Just add echos
for PHP and correct <iframe src="CORRECT THIS FIELD">
attribute, also set image url to something that really exists.
In place of document.body
you could use for example '#myWebGLArea'
and add <div id="myWebGLArea"></div>
to your page.
Also check out WebGL detection script at https://gist.github.com/1709384 and another Q/A https://stackoverflow.com/a/9904965/1338846