<script type="text/javascript">
var _bdhm_top = 0;
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
var _bdhm_tim = new Image(1,1);
_bdhm_tim.id = "bdhmPerimg";
_bdhm_tim.src = _bdhmProtocol + "hm.baidu.com/_tt.gif?si=d509632f498554589945c26c5d3d5cec&rnd=" + Math.round(Math.random()*2147483647);
_bdhm_tim.onload=function(){_bdhm_top = 1;}alert(Math.round(Math.random()*2147483647);
</script>
求这段代码的解释
谢谢

解决方案 »

  1.   

    <script type="text/javascript">
    var _bdhm_top = 0;//定义全局变量
    var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");//判断当前页面的协议,如果等于https此变量就等于https://此变量等于http://
    var _bdhm_tim = new Image(1,1);//初始化Image函数;
    _bdhm_tim.id = "bdhmPerimg";//函数id等于bdhmPerimg
    _bdhm_tim.src = _bdhmProtocol + "hm.baidu.com/_tt.gif?si=d509632f498554589945c26c5d3d5cec&rnd=" + Math.round(Math.random()*2147483647);//函数的src为http://或者https://加上"hm.baidu.com/_tt.gif?si=d509632f498554589945c26c5d3d5cec&rnd=" rnd后面是随机数
    _bdhm_tim.onload=function(){_bdhm_top = 1;}//页面加载成功后变量bdhm_top等于1alert(Math.round(Math.random()*2147483647);//弹出上面的随机数
    </script>