当前位置:编程学习 > C#/ASP.NET >>

js调用问题

我想将前台的js放到一个文件中然后从再从前台调用这个文件 请问应该如何写原js如下
<script language=javascript type="text/javascript">
//*焦点切换
(function(){
if(!Function.prototype.bind){
Function.prototype.bind = function(obj){
var owner = this,args = Array.prototype.slice.call(arguments),callobj = Array.prototype.shift.call(args);
return function(e){e=e||top.window.event||window.event;owner.apply(callobj,args.concat([e]));};
};
}
})();
var player = function(id){
this.ctn = document.getElementById(id);
this.adLis = null;
//this.btns = null;
this.animStep = 0.2;//动画速度0.1~0.9
this.switchSpeed = 3;//自动播放间隔(s)
this.defOpacity = 1;
this.tmpOpacity = 1;
this.crtIndex = 0;
this.crtLi = null;
this.adLength = 0;
this.timerAnim = null;
this.timerSwitch = null;
this.init();
};
player.prototype = {
fnAnim:function(toIndex){
if(this.timerAnim){window.clearTimeout(this.timerAnim);}
if(this.tmpOpacity <= 0){
this.crtLi.style.opacity = this.tmpOpacity = this.defOpacity;
this.crtLi.style.filter = 'Alpha(Opacity=' + this.defOpacity*100 + ')';
this.crtLi.style.zIndex = 0;
this.crtIndex = toIndex;
return;
}
this.crtLi.style.opacity = this.tmpOpacity = this.tmpOpacity - this.animStep;
this.crtLi.style.filter = 'Alpha(Opacity=' + this.tmpOpacity*100 + ')';
this.timerAnim = window.setTimeout(this.fnAnim.bind(this,toIndex),50);
},
fnNextIndex:function(){
return (this.crtIndex >= this.adLength-1)?0:this.crtIndex+1;
},
fnSwitch:function(toIndex){
if(this.crtIndex==toIndex){return;}
this.crtLi = this.adLis[this.crtIndex];
for(var i=0;i<this.adLength;i++){
this.adLis[i].style.zIndex = 0;
}
this.crtLi.style.zIndex = 2;
this.adLis[toIndex].style.zIndex = 1;
for(var i=0;i<this.adLength;i++){
//this.btns[i].className = '';
}
//this.btns[toIndex].className = 'on'
this.fnAnim(toIndex);
},
fnAutoPlay:function(){
this.fnSwitch(this.fnNextIndex());
},
fnPlay:function(){
this.timerSwitch = window.setInterval(this.fnAutoPlay.bind(this),this.switchSpeed*1000);
},
fnStopPlay:function(){
window.clearTimeout(this.timerSwitch);
},
init:function(){
this.adLis = this.ctn.getElementsByTagName('li');
//this.btns = this.ctn.getElementsByTagName('cite')[0].getElementsByTagName('span');
this.adLength = this.adLis.length;
//for(var i=0,l=this.btns.length;i<l;i++){
//with({i:i}){
//this.btns[i].index = i;
//this.btns[i].onclick = this.fnSwitch.bind(this,i);
//this.btns[i].onclick = this.fnSwitch.bind(this,i);
//}
//}
this.adLis[this.crtIndex].style.zIndex = 2;
this.fnPlay();
this.ctn.onmouseover = this.fnStopPlay.bind(this);
this.ctn.onmouseout = this.fnPlay.bind(this);
}
};
var player1 = new player('player');
</script> 
--------------------编程问答-------------------- <script src="../../JS/swfobject.js" type="text/javascript"></script>
红字是你文件路径 --------------------编程问答--------------------
引用 1 楼 dcy1101521 的回复:
<script src="../../JS/swfobject.js" type="text/javascript"></script>
红字是你文件路径

<html>
<head>
<script src="../../JS/swfobject.js" type="text/javascript"></script>
<script type=''>
这里面可以直接用或者在body的控件中都可以直接调用了
地址添写正确就行了
</script>
</head>
<body></body></html> --------------------编程问答-------------------- 试了 不管用 不知道还需要改什么东西 --------------------编程问答-------------------- 我只是将那些脚本复制到一个文件中 然后页面中只写了<script src="../../JS/swfobject.js" type="text/javascript"></script>  这样不行
--------------------编程问答-------------------- 调试,页面F12然后看脚本调用到了没...没调用到就是路径问题了.... --------------------编程问答-------------------- asp的网站 不过路径没有问题 --------------------编程问答-------------------- 你没有把<script language=javascript type="text/javascript">
这句复制进去吧? --------------------编程问答-------------------- 没有 除了前一句和后一句都复制进去了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,