我想根据WebGL支持来决定要在Rails应用程序中呈现哪些内容。
我知道我可以从JS检查WebGL
if (!window.WebGLRenderingContext) {
return; }
但是,如何使用它来决定在html.erb中呈现什么呢?
我想要类似的东西
if (!window.WebGLRenderingContext) {
// Use some <%= rails_helper %>
}else{
// <%= use_another_rails_helper %>
}
这是您要找的吗?
if(!window.WebGLRenderingContext) {
$("#div_id").html(<%= rails_helper %>);
}
else {
$("#div_id").html(<%= use_another_rails_helper %>);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句