Feed on
Posts
Comments

Category Archive for 'javascript'

因为网络问题,页面加载的速度不一致,导致一些js出错。
所以我们经常需要在页面都加载完成后再执行相应的js操作,那样才会避免很多麻烦和意外。
使用方法:
EF.onReady(functionName);
例:
EF.onReady(function a(){alert(document.getElementById);});
EF.onReady(function b(){alert(document.lastChild);});
<script type=”text/javascript”>
var EF = {
isGecko: function()
{
return navigator.userAgent.indexOf(”Gecko”) == -1 ? false :true;
},

isOpera: function()
{
return navigator.userAgent.indexOf(”Opera”) == -1 ? false :true;
},

isIE: function()
{
return document.all ?  true : false;
},

onReady: function(newFunction)
{
if(newFunction == undefined)
return false;

this.domReady = false;

[...]

查看所有 »