[英]Fallback from CSS3 to Javascript
The method i am trying to use is like this: 我试图使用的方法是这样的:
My question is : 我的问题是:
How can I download a JS file into the users browser? 如何将JS文件下载到用户浏览器中? Is this even possible?
这有可能吗? What other methods do you suggest?
您还建议其他什么方法?
PS: Really new in this domain so please help! PS:在这个领域真的很新,所以请帮忙! Thank you!
谢谢!
Why downloading a script later? 为什么以后要下载脚本? Put the script directly in the head and wrap it in an if-else-clause so that it do nothing, if CSS3 is available...
将脚本直接放在头部,然后将其包装在if-else-clause中,以便在CSS3可用的情况下不执行任何操作...
Otherwise you can change the DOM and place a new script in the head... 否则,您可以更改DOM并将新脚本放在头部...
This is a very simple implementation that checks for css transition support and, if it does not exist, loads an external JS file: 这是一个非常简单的实现,用于检查CSS过渡支持,如果不存在,则加载外部JS文件:
HTML 的HTML
<!-- make sure you include <script> link to to modernizr.js in your <head> before this script -->
<script>
// if browser does not support transitions. If not, load in our polyfill
Modernizr.load({
test: Modernizr.csstransitions,
nope: '/js/polyfill.js'
});// END Modernizr.load
</script>
Additionally here is a list of polyfills that you can use to reproduce modern functionality in older browsers (be cautious here though, there can be a large performance hit). 此外,这里还有一个polyfill列表,可用于在较旧的浏览器中重现现代功能(不过请谨慎,此处可能会严重影响性能)。
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.