| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 803 人关注过本帖
标题:[求助]调用函数,onload载入实现这2个特效?
只看楼主 加入收藏
renqian1320
Rank: 1
等 级:新手上路
帖 子:126
专家分:0
注 册:2005-6-27
收藏
 问题点数:0 回复次数:4 
[求助]调用函数,onload载入实现这2个特效?

<head>
<script type="text/javascript">
// 7 variables to control behavior
var Car_Image_Width=140;
var Car_Image_Height=225;
var Car_Border=true; // true or false
var Car_Border_Color="white";
var Car_Speed=4;
var Car_Direction=true; // true or false
var Car_NoOfSides=8; // must be 4, 6, 8 or 12

/* array to specify images and optional links.
For 4 sided carousel specify at least 2 images
For 6 sided carousel specify at least 3
For 8 sided carousel specify at least 4
For 12 sided carousel specify at least 6
If Link is not needed keep it ""
*/
Car_Image_Sources=new Array(
"photo/200310171/photo1.jpg","http://www.cctv.com",
"photo/200310171/photo2.jpg","http://www.cctv.com",
"photo/200310171/photo3.jpg","", //this slide isn't linked
"photo/200310171/photo4.jpg","http://www.cctv.com" // NOTE No comma after last line
);

/***************** DO NOT EDIT BELOW **********************************/
CW_I=new Array(Car_NoOfSides/2+1);C_ClcW=new Array(Car_NoOfSides/2);
C_Coef=new Array(
3*Math.PI/2,0,3*Math.PI/2,11*Math.PI/6,Math.PI/6,3*Math.PI/2,7*Math.PI/4, 0,
Math.PI/4,3*Math.PI/2,5*Math.PI/3,11*Math.PI/6,0,Math.PI/6,Math.PI/3);
var C_CoefOf=Car_NoOfSides==4?0:Car_NoOfSides==6?2:Car_NoOfSides==8?5:9;
C_Pre_Img=new Array(Car_Image_Sources.length);
var C_Angle=Car_Direction?Math.PI/(Car_NoOfSides/2):0,C_CrImg=Car_NoOfSides,C_MaxW,C_TotalW,
C_Stppd=false,i,C_LeftOffset,C_HalfNo=Car_NoOfSides/2;

function Carousel(){
if(document.getElementById){
for(i=0;i<Car_Image_Sources.length;i+=2){
C_Pre_Img[i]=new Image();C_Pre_Img[i].src=Car_Image_Sources[i]}
C_MaxW=Car_Image_Width/Math.sin(Math.PI/Car_NoOfSides)+C_HalfNo+1;
Car_Div=document.getElementById("Carousel");
for(i=0;i<C_HalfNo;i++){
CW_I[i]=document.createElement("img");Car_Div.appendChild(CW_I[i]);
CW_I[i].style.position="absolute";
CW_I[i].style.top=0+"px";
CW_I[i].style.height=Car_Image_Height+"px";
if(Car_Border){
CW_I[i].style.borderStyle="solid";
CW_I[i].style.borderWidth=1+"px";
CW_I[i].style.borderColor=Car_Border_Color}
CW_I[i].src=Car_Image_Sources[2*i];
CW_I[i].lnk=Car_Image_Sources[2*i+1];
CW_I[i].onclick=C_LdLnk;
CW_I[i].onmouseover=C_Stp;
CW_I[i].onmouseout=C_Rstrt}
CarImages()}}

function CarImages(){
if(!C_Stppd){
C_TotalW=0;
for(i=0;i<C_HalfNo;i++){
C_ClcW[i]=Math.round(Math.cos(Math.abs(C_Coef[C_CoefOf+i]+C_Angle))*Car_Image_Width);
C_TotalW+=C_ClcW[i]}
C_LeftOffset=(C_MaxW-C_TotalW)/2;
for(i=0;i<C_HalfNo;i++){
CW_I[i].style.left=C_LeftOffset+"px";
CW_I[i].style.width=C_ClcW[i]+"px";
C_LeftOffset+=C_ClcW[i]}
C_Angle+=Car_Speed/720*Math.PI*(Car_Direction?-1:1);
if((Car_Direction&&C_Angle<=0)||(!Car_Direction&&C_Angle>=Math.PI/C_HalfNo)){
if(C_CrImg==Car_Image_Sources.length)C_CrImg=0;
if(Car_Direction){
CW_I[C_HalfNo]=CW_I[0];
for(i=0;i<C_HalfNo;i++)CW_I[i]=CW_I[i+1];
CW_I[C_HalfNo-1].src=Car_Image_Sources[C_CrImg];
CW_I[C_HalfNo-1].lnk=Car_Image_Sources[C_CrImg+1]}
else{ for(i=C_HalfNo;i>0;i--)CW_I[i]=CW_I[i-1];
CW_I[0]=CW_I[C_HalfNo];
CW_I[0].src=Car_Image_Sources[C_CrImg];
CW_I[0].lnk=Car_Image_Sources[C_CrImg+1]}
C_Angle=Car_Direction?Math.PI/C_HalfNo:0;C_CrImg+=2}}
setTimeout("CarImages()",50)}

function C_LdLnk(){if(this.lnk)window.location.href=this.lnk}
function C_Stp(){this.style.cursor=this.lnk?"pointer":"default";C_Stppd=true;}
function C_Rstrt(){C_Stppd=false}
</script>

<script language="javascript">
var yourwords = "欢迎光临南京电视台网站!!!";

var speed = 700;

var control = 1;

function flash()

{

if (control == 1)

{

window.status=yourwords;

control=0;

}

else

{

window.status="";

control=1;

}

setTimeout("flash()",speed);

}

// -->

</script>

</head>
<body onLoad="Carousel()">
<div id="Carousel" style="position:relative">
<img src="photo/200310171/placeholder.gif" width="371" height="225">
</div>
</body>
问题如下:第一段是一个图片旋转的代码.在onload事件时显示,
第二段代码是状态拦显示"欢迎光临南京电视台网站!!!";也是在onload事件时显示.
我想这2段代码在页面加载时同时显示,请问怎么样实现?????赐教 第一次时,我写了个函数function abs(){function Carousel();function flash();>
这样<body onload="abs()>
这样成功的实现了,页面载入时实现了效果,但是第2天早上一来,我迷糊迷糊的,不知道这个新函数具体放在哪了,急.头脑真的好累.希望知道的说下.

搜索更多相关主题的帖子: javascript control images false 
2006-05-08 02:13
阳光白雪
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:39
帖 子:2220
专家分:0
注 册:2005-11-18
收藏
得分:0 

专注于WEB前端交互平台开发:[url=http://blog./]blog.[/url](富客户端技术(RIA)交流平台)
2006-05-08 08:33
renqian1320
Rank: 1
等 级:新手上路
帖 子:126
专家分:0
注 册:2005-6-27
收藏
得分:0 
就是2个特效,在页面onload事件时,同时有这2个效果,这2个特效都是onload事件发生的

2006-05-08 12:49
小笨笨
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:1169
专家分:0
注 册:2006-4-17
收藏
得分:0 
你把两个特效代码都放在abs()不行吗?

欢迎光临我的博客: http://smallfools.blog./default.html
2006-05-17 14:13
木木夕糹力
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-5-11
收藏
得分:0 
看不懂哦!!太深了~~
2006-05-17 16:20
快速回复:[求助]调用函数,onload载入实现这2个特效?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028957 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved