条件jQuery实现
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了条件jQuery实现相关的知识,希望对你有一定的参考价值。
1) if jQuery is already loaded into a browsers' cache -> do nothing2) if the object is undefined, write a script-element into the source which references google's minified jquery file.
3) if jQuery is still undefined (let's assume Google is down). write a script reference to our local copy into the source.
You could also use the if statements to define different JS files for the frontend and the backend.
(as seen on www.ie6update.com)
/* only load jQuery if not present */ if(typeof jQuery == 'undefined') { document.write("<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></"+"script>"); var __noconflict = true; } </script> <script type="text/javascript"> /* if Google is down */ if(typeof jQuery == 'undefined') { document.write("<script type="text/javascript" src="/lib/js/jquery.min.js"></"+"script>"); var __noconflict = true; } </script> <script type="text/javascript" src="/lib/js/functions.js"></script>
以上是关于条件jQuery实现的主要内容,如果未能解决你的问题,请参考以下文章