遇到一个很奇怪的问题。使用如下两个js其中一个的时候是可以运行的。但是如果一起使用的时候,rep(name)这个函数的第一句就会报错。<script type="text/javascript">
function rep(name) {
if(document.getElementById(name).src.substring(document.getElementById(name).src.length-12) == "_clicked.png") return ; document.getElementById("renwuxiada").src = "../img/renwuxiada.png";
document.getElementById("lishichaxun").src = "../img/lishichaxun.png";
document.getElementById("xiaoxidingzhi").src = "../img/xiaoxidingzhi.png";
document.getElementById("yonghuxinxi").src = "../img/yonghuxinxi.png";
document.getElementById(name).src = "../img/" + name + "_clicked.png";
}
</script>或者<!--右下脚弹出窗口开始-->
//window.onload = getMsg;
window.onresize = resizeDiv;
//window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;function getMsg()
{
try
{
divTop = parseInt(document.getElementById("loft_win").style.top,10);
divLeft = parseInt(document.getElementById("loft_win").style.left,10);
divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10);
divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("loft_win").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
document.getElementById("loft_win").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
document.getElementById("loft_win").style.visibility="visible";
objTimer = window.setInterval("moveDiv()",10);
}
catch(e){}
}//初始化位置
function resizeDiv()
{
i+=1;
//if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句
try
{
divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10);
divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("loft_win").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
document.getElementById("loft_win").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
}
catch(e){}
}//移动
function moveDiv()
{
try
{
if(parseInt(document.getElementById("loft_win").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer);
objTimer = window.setInterval("resizeDiv()",1);
}
divTop = parseInt(document.getElementById("loft_win").style.top,10);
document.getElementById("loft_win").style.top = divTop -1;
}
catch(e){}
}function minDiv()
{
closeDiv();
document.getElementById('loft_win_min').style.visibility='visible';
objTimer = window.setInterval("minsizeDiv()",1);
}function maxDiv()
{
document.getElementById('loft_win_min').style.visibility='hidden';
document.getElementById('loft_win').style.visibility='visible';
objTimer = window.setInterval("resizeDiv()",1);
//resizeDiv()
getMsg();
}function closeDiv()
{
document.getElementById('loft_win').style.visibility='hidden';
document.getElementById('loft_win_min').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer);
}
<!--右下脚弹出窗口结束-->
function rep(name) {
if(document.getElementById(name).src.substring(document.getElementById(name).src.length-12) == "_clicked.png") return ; document.getElementById("renwuxiada").src = "../img/renwuxiada.png";
document.getElementById("lishichaxun").src = "../img/lishichaxun.png";
document.getElementById("xiaoxidingzhi").src = "../img/xiaoxidingzhi.png";
document.getElementById("yonghuxinxi").src = "../img/yonghuxinxi.png";
document.getElementById(name).src = "../img/" + name + "_clicked.png";
}
</script>或者<!--右下脚弹出窗口开始-->
//window.onload = getMsg;
window.onresize = resizeDiv;
//window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;function getMsg()
{
try
{
divTop = parseInt(document.getElementById("loft_win").style.top,10);
divLeft = parseInt(document.getElementById("loft_win").style.left,10);
divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10);
divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("loft_win").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
document.getElementById("loft_win").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
document.getElementById("loft_win").style.visibility="visible";
objTimer = window.setInterval("moveDiv()",10);
}
catch(e){}
}//初始化位置
function resizeDiv()
{
i+=1;
//if(i>300) closeDiv() //想不用自动消失由用户来自己关闭所以屏蔽这句
try
{
divHeight = parseInt(document.getElementById("loft_win").offsetHeight,10);
divWidth = parseInt(document.getElementById("loft_win").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("loft_win").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
document.getElementById("loft_win").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
}
catch(e){}
}//移动
function moveDiv()
{
try
{
if(parseInt(document.getElementById("loft_win").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer);
objTimer = window.setInterval("resizeDiv()",1);
}
divTop = parseInt(document.getElementById("loft_win").style.top,10);
document.getElementById("loft_win").style.top = divTop -1;
}
catch(e){}
}function minDiv()
{
closeDiv();
document.getElementById('loft_win_min').style.visibility='visible';
objTimer = window.setInterval("minsizeDiv()",1);
}function maxDiv()
{
document.getElementById('loft_win_min').style.visibility='hidden';
document.getElementById('loft_win').style.visibility='visible';
objTimer = window.setInterval("resizeDiv()",1);
//resizeDiv()
getMsg();
}function closeDiv()
{
document.getElementById('loft_win').style.visibility='hidden';
document.getElementById('loft_win_min').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer);
}
<!--右下脚弹出窗口结束-->
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货