新手求助JS图片切换 谁能帮我注释一下代码的大概意思 特别是切换效果的地方
vardo_transition,key=0,imgNum=0,countUrl=0,Loop;for(v=0;v<imgUrl.length;v++){if(imgUr...
var do_transition,key=0,imgNum=0,countUrl=0,Loop;
for(v=0;v<imgUrl.length;v++){if(imgUrl[v]!=''){countUrl++;}else{break;}}
if(countUrl==0){imgUrl[1]='../../images/alz_zanwu.jpg'; imgLink[1]="#";imgAlt[1]="";imgtext[1]="";}
var count=countUrl-1;
function $(id){return document.getElementById(id);}
function goUrl(){if(imgLink[imgNum]!="#"){window.open(imgLink[imgNum],target);}}
function changeimg(n){imgNum=n;clearInterval(Loop);imgNum=imgNum-1;nextAd();}
function nextAd(){
if(imgNum<count){imgNum++;} else{imgNum=1;}
if(imgLink[imgNum]=="#"){$("Rollimg").style.cursor="";$("Textstr").style.cursor="";}else{$("Rollimg").style.cursor="pointer";$("Textstr").style.cursor="pointer";}
if(key==0){key=1;}else if(document.all){
if(current_transition==transition_count){do_transition=Math.floor(Math.random()*transition_count);}else{do_transition=current_transition;}
$("Rollimg").style.filter=transitions[do_transition];
$("Rollimg").filters[0].Apply();
$("Rollimg").filters[0].Play();
}
$("Rollimg").src=imgUrl[imgNum];
$("Textstr").title=imgAlt[imgNum];
$("Textstr").innerHTML=imgtext[imgNum];
if($("link"+imgNum))$("link"+imgNum).className="buttonOn";
for (var i=1;i<=count;i++){if(i!=imgNum){$("link"+i).className="button";}}
Loop=setTimeout("nextAd()",TimeOut);
}
document.write('<div class="'+cssname+'">');
document.write('<img id="Rollimg" onclick="goUrl();" />');
document.write('<div id="buttons">');
for(var i=1;i<countUrl;i++){document.write('<a id="link'+i+'" onclick="changeimg('+i+');" class="button">'+i+'</a>');}
document.write('</div>');
document.write('<div id="Textstr" onclick="goUrl()"></div>');
document.write('</div>');
nextAd();
noright2(window.document);
function noright2(obj){
obj.oncontextmenu = function(){return false;}
obj.ondragstart = function(){return false;}
obj.onselectstart = function(){return false;}
obj.onselect = function(){document.selection.empty();}
obj.oncopy = function(){document.selection.empty();}
obj.onbeforecopy = function(){return false;}
} 展开
for(v=0;v<imgUrl.length;v++){if(imgUrl[v]!=''){countUrl++;}else{break;}}
if(countUrl==0){imgUrl[1]='../../images/alz_zanwu.jpg'; imgLink[1]="#";imgAlt[1]="";imgtext[1]="";}
var count=countUrl-1;
function $(id){return document.getElementById(id);}
function goUrl(){if(imgLink[imgNum]!="#"){window.open(imgLink[imgNum],target);}}
function changeimg(n){imgNum=n;clearInterval(Loop);imgNum=imgNum-1;nextAd();}
function nextAd(){
if(imgNum<count){imgNum++;} else{imgNum=1;}
if(imgLink[imgNum]=="#"){$("Rollimg").style.cursor="";$("Textstr").style.cursor="";}else{$("Rollimg").style.cursor="pointer";$("Textstr").style.cursor="pointer";}
if(key==0){key=1;}else if(document.all){
if(current_transition==transition_count){do_transition=Math.floor(Math.random()*transition_count);}else{do_transition=current_transition;}
$("Rollimg").style.filter=transitions[do_transition];
$("Rollimg").filters[0].Apply();
$("Rollimg").filters[0].Play();
}
$("Rollimg").src=imgUrl[imgNum];
$("Textstr").title=imgAlt[imgNum];
$("Textstr").innerHTML=imgtext[imgNum];
if($("link"+imgNum))$("link"+imgNum).className="buttonOn";
for (var i=1;i<=count;i++){if(i!=imgNum){$("link"+i).className="button";}}
Loop=setTimeout("nextAd()",TimeOut);
}
document.write('<div class="'+cssname+'">');
document.write('<img id="Rollimg" onclick="goUrl();" />');
document.write('<div id="buttons">');
for(var i=1;i<countUrl;i++){document.write('<a id="link'+i+'" onclick="changeimg('+i+');" class="button">'+i+'</a>');}
document.write('</div>');
document.write('<div id="Textstr" onclick="goUrl()"></div>');
document.write('</div>');
nextAd();
noright2(window.document);
function noright2(obj){
obj.oncontextmenu = function(){return false;}
obj.ondragstart = function(){return false;}
obj.onselectstart = function(){return false;}
obj.onselect = function(){document.selection.empty();}
obj.oncopy = function(){document.selection.empty();}
obj.onbeforecopy = function(){return false;}
} 展开
展开全部
我从底下给你写,再有不会的,请来问我。
var do_transition,key=0,imgNum=0,countUrl=0,Loop;
for(v=0;v<imgUrl.length;v++){if(imgUrl[v]!=''){countUrl++;}else{break;}}
if(countUrl==0){imgUrl[1]='../../images/alz_zanwu.jpg'; imgLink[1]="#";imgAlt[1]="";imgtext[1]="";}
var count=countUrl-1;
function $(id){return document.getElementById(id);}
function goUrl(){if(imgLink[imgNum]!="#"){window.open(imgLink[imgNum],target);}}
function changeimg(n){imgNum=n;clearInterval(Loop);imgNum=imgNum-1;nextAd();}
function nextAd(){
if(imgNum<count){imgNum++;} else{imgNum=1;}
if(imgLink[imgNum]=="#"){$("Rollimg").style.cursor="";$("Textstr").style.cursor="";}else{$("Rollimg").style.cursor="pointer";$("Textstr").style.cursor="pointer";}
if(key==0){key=1;}else if(document.all){
if(current_transition==transition_count){do_transition=Math.floor(Math.random()*transition_count);}else{do_transition=current_transition;}
$("Rollimg").style.filter=transitions[do_transition];
$("Rollimg").filters[0].Apply();
$("Rollimg").filters[0].Play(); //播放所有幻灯片
}
$("Rollimg").src=imgUrl[imgNum];//加上幻灯片上的超链接
$("Textstr").title=imgAlt[imgNum];//幻灯片上的数字编号
$("Textstr").innerHTML=imgtext[imgNum];//加载所有输出图片号码
if($("link"+imgNum))$("link"+imgNum).className="buttonOn";//当选择时,执行超链接,与开启buttonOn
for (var i=1;i<=count;i++){if(i!=imgNum){$("link"+i).className="button";}}//循环输出所有的图片信息,类名为button,就是所有的已设置的
Loop=setTimeout("nextAd()",TimeOut);//设置超时,函数
}
document.write('<div class="'+cssname+'">');//输出cssnane类名
document.write('<img id="Rollimg" onclick="goUrl();" />');//输出,当点击时,触发goUrl
document.write('<div id="buttons">');
for(var i=1;i<countUrl;i++){document.write('<a id="link'+i+'" onclick="changeimg('+i+');" class="button">'+i+'</a>');}//输出了一个超链接
document.write('</div>');//输出结束符
document.write('<div id="Textstr" onclick="goUrl()"></div>');//输出一个id的div
document.write('</div>');//输出结束符
nextAd();
noright2(window.document);
function noright2(obj){定义一个函数名
obj.oncontextmenu = function(){return false;}//执行函数
obj.ondragstart = function(){return false;}//执行函数
obj.onselectstart = function(){return false;}//执行函数
obj.onselect = function(){document.selection.empty();}//,且选择项清空
obj.oncopy = function(){document.selection.empty();}//执行函数,且选择项清空
obj.onbeforecopy = function(){return false;}//执行函数
}
var do_transition,key=0,imgNum=0,countUrl=0,Loop;
for(v=0;v<imgUrl.length;v++){if(imgUrl[v]!=''){countUrl++;}else{break;}}
if(countUrl==0){imgUrl[1]='../../images/alz_zanwu.jpg'; imgLink[1]="#";imgAlt[1]="";imgtext[1]="";}
var count=countUrl-1;
function $(id){return document.getElementById(id);}
function goUrl(){if(imgLink[imgNum]!="#"){window.open(imgLink[imgNum],target);}}
function changeimg(n){imgNum=n;clearInterval(Loop);imgNum=imgNum-1;nextAd();}
function nextAd(){
if(imgNum<count){imgNum++;} else{imgNum=1;}
if(imgLink[imgNum]=="#"){$("Rollimg").style.cursor="";$("Textstr").style.cursor="";}else{$("Rollimg").style.cursor="pointer";$("Textstr").style.cursor="pointer";}
if(key==0){key=1;}else if(document.all){
if(current_transition==transition_count){do_transition=Math.floor(Math.random()*transition_count);}else{do_transition=current_transition;}
$("Rollimg").style.filter=transitions[do_transition];
$("Rollimg").filters[0].Apply();
$("Rollimg").filters[0].Play(); //播放所有幻灯片
}
$("Rollimg").src=imgUrl[imgNum];//加上幻灯片上的超链接
$("Textstr").title=imgAlt[imgNum];//幻灯片上的数字编号
$("Textstr").innerHTML=imgtext[imgNum];//加载所有输出图片号码
if($("link"+imgNum))$("link"+imgNum).className="buttonOn";//当选择时,执行超链接,与开启buttonOn
for (var i=1;i<=count;i++){if(i!=imgNum){$("link"+i).className="button";}}//循环输出所有的图片信息,类名为button,就是所有的已设置的
Loop=setTimeout("nextAd()",TimeOut);//设置超时,函数
}
document.write('<div class="'+cssname+'">');//输出cssnane类名
document.write('<img id="Rollimg" onclick="goUrl();" />');//输出,当点击时,触发goUrl
document.write('<div id="buttons">');
for(var i=1;i<countUrl;i++){document.write('<a id="link'+i+'" onclick="changeimg('+i+');" class="button">'+i+'</a>');}//输出了一个超链接
document.write('</div>');//输出结束符
document.write('<div id="Textstr" onclick="goUrl()"></div>');//输出一个id的div
document.write('</div>');//输出结束符
nextAd();
noright2(window.document);
function noright2(obj){定义一个函数名
obj.oncontextmenu = function(){return false;}//执行函数
obj.ondragstart = function(){return false;}//执行函数
obj.onselectstart = function(){return false;}//执行函数
obj.onselect = function(){document.selection.empty();}//,且选择项清空
obj.oncopy = function(){document.selection.empty();}//执行函数,且选择项清空
obj.onbeforecopy = function(){return false;}//执行函数
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询