主站
经典论坛
家园
作品
品网
维基
桌面
聚合
注册
登录
专长会员
帮助
客服QQ:6650171
经典论坛
»
前台制作与脚本专栏
» 寻一飘动flash广告的js代码
‹‹ 上一主题
|
下一主题 ››
发新话题
发布投票
发布商品
发布悬赏
发布活动
发布辩论
发布视频
打印
寻一飘动flash广告的js代码
dilong
[楼主]
高级会员
帖子
299
体力
937
威望
0
当前
山东 烟台
离线
22 天
发短消息
加为好友
1
#
大
中
小
发表于 2004-11-23 15:19
要求可以 自己设置 飘动的速度
fulltime worker
积分
937
阅读权限
50
性别
男
在线时间
135 小时
注册时间
2004-5-21
最后登录
2009-6-12
查看详细资料
TOP
西部数码VPS主机1G内存仅266元
dzyuan
禁止发言
帖子
161
体力
645
威望
0
离线
1639 天
发短消息
加为好友
2
#
大
中
小
发表于 2004-11-23 17:56
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>图片随机飘动代码生成器</title> <style type="text/css"> body { text-align:center } table td { font-size:9pt; } </style> <script language="JavaScript"> <!-- function fn_getValueRadio(form_name) { var value = ""; for (var i=0; i<form_name.length;i++) { if (form_name[i].checked) { value = form_name[i].value; break; } } return value; } function fn_display(form_name) { var display = fn_getValueRadio(form_name); if (display == "flash") { document.getElementById("image").style.display = "none" document.getElementById("imageUrl").style.display = "none" document.getElementById("flash").style.display = "" } else if (display == "image") { document.getElementById("image").style.display = "" document.getElementById("imageUrl").style.display = "" document.getElementById("flash").style.display = "none" } } function JM_cc(ob) { ob.select(); js=ob.createTextRange(); js.execCommand("Copy"); } function fn_createCode(form_name) { //生成飘动的层 var display = fn_getValueRadio(form_name.type); var div_html = ""; if (display == "image") { var imgPath = form_name.imgPath.value; var imgHeight = form_name.imgHeight.value; var imgWidth = form_name.imgWidth.value; var imgUrl = form_name.imgUrl.value; var mouse = fn_getValueRadio(form_name.mouse) if (imgPath == "") { alert("请输入飘动图片的路径") return; } if ((imgHeight == "")||((imgHeight != "")&&(!isNumber(imgHeight)))) { alert("图片的高度不能为空且只能为数字") return; } if ((imgWidth == "")||((imgWidth != "")&&(!isNumber(imgWidth)))) { alert("图片的宽度不能为空且只能为数字") return; } if (mouse == "1") { if (imgUrl != "") div_html += "<span id='img' style='position:absolute;' onmouseover='mystop()' onmouseout= 'start()'><a href='"+imgUrl+"' target='_blank'><img src='"+imgPath+"' width='"+imgHeight+"' height='"+imgWidth+"' border='0'> </a></span>" else div_html += "<span id='img' style='position:absolute;' onmouseover='mystop()' onmouseout= 'start()'><img src='"+imgPath+"' width='"+imgHeight+"' height='"+imgWidth+"'></span>" } else { if (imgUrl != "") div_html += "<span id='img' style='position:absolute;'><a href='"+imgUrl+"' target='_blank'><img src='"+imgPath+"' width='"+imgHeight+"' height='"+imgWidth+"' border='0'> </a></span>" else div_html += "<span id='img' style='position:absolute;'><img src='"+imgPath+"' width='"+imgHeight+"' height='"+imgWidth+"'></span>" } } else if (display == "flash") { var fPath = form_name.fPath.value; var fHeight = form_name.fHeight.value; var fWidth = form_name.fWidth.value; var fmouse = fn_getValueRadio(form_name.mouse) if (fPath == "") { alert("请输入飘动flash的路径") return; } if ((fHeight == "")||((fHeight != "")&&(!isNumber(fHeight)))) { alert("flash的高度不能为空且只能为数字") return; } if ((fWidth == "")||((fWidth != "")&&(!isNumber(fWidth)))) { alert("flash的宽度不能为空且只能为数字") return; } if (fmouse == "1") { div_html += "<span id='img' style='position:absolute;' onmouseover='mystop()' onmouseout= 'start()'>"; div_html += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+fWidth+"' height='"+fHeight+"'>"; div_html += "<param name='movie' value='"+fPath+"'>"; div_html += "<param name='quality' value='high'>" div_html += "<embed src='"+fPath+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+fWidth+"' height='"+fHeight+"'></embed></object></span>"; } else { div_html += "<span id='img' style='position:absolute;'>"; div_html += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+fWidth+"' height='"+fHeight+"'>"; div_html += "<param name='movie' value='"+fPath+"'>"; div_html += "<param name='quality' value='high'>" div_html += "<embed src='"+fPath+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+fWidth+"' height='"+fHeight+"'></embed></object></span>"; } } //设置飘动参数生成飘动代码 var code_html = ""; var position = fn_getValueRadio(form_name.imgPosition); var xPos = 0; var yPos = 0; switch (position) { case "topLeft": xPos = 0; yPos = 0; break; case "topCenter": xPos = parseInt(document.body.clientWidth/2); yPos = 0; break; case "topRight": xPos = document.body.clientWidth; yPos = 0; break; case "bottomLeft": xPos = 0; yPos = document.body.clientHeight; break; case "bottomCenter": xPos = parseInt(document.body.clientWidth/2); yPos = document.body.clientHeight; break; case "bottomRight": xPos = document.body.clientWidth; yPos = document.body.clientHeight; break; } var delay_time = parseInt(fn_getValueRadio(form_name.delay)) var delay = 0; switch (delay_time) { case 5: delay = 5 break; case 10: delay = 10 break; case 20: delay = 20 break; case 30: delay =30 break; case 40: delay = 40 break; case 50: delay = 50 break; } code_html += "\r\n<script language='JavaScript'>\r\n" code_html += "var xPos = "+xPos+";var yPos = "+yPos+"; var step = 1;var delay = "+delay+";var height = 0; var Hoffset = 0;var Woffset = 0; var yon = 0;var xon = 0; var xon = 0; var interval;\r\n"; code_html += "var img = document.getElementById('img');\r\n" code_html += "img.style.top = "+yPos+";\r\n"; code_html +="function changePos(){\r\n" code_html += "width = document.body.clientWidth;\r\n" code_html += "height = document.body.clientHeight;\r\n" code_html += "Hoffset = img.offsetHeight;\r\n" code_html += "Woffset = img.offsetWidth;\r\n" code_html += "img.style.left = xPos + document.body.scrollLeft;\r\n" code_html += "img.style.top = yPos + document.body.scrollTop;\r\n" code_html += "if (yon) {\r\n" code_html += "yPos = yPos + step;\r\n" code_html += "\r\n}" code_html += "else {\r\n" code_html += "yPos = yPos - step;\r\n" code_html += "}\r\n" code_html += "if (yPos < 0) {\r\n" code_html += "yon = 1;\r\n" code_html += "yPos = 0;\r\n" code_html += "}\r\n" code_html += "if (yPos >= (height - Hoffset)) {\r\n" code_html += "yon = 0;\r\n" code_html += "yPos = (height - Hoffset);\r\n" code_html += "}\r\n" code_html += "if (xon) {\r\n" code_html += "xPos = xPos + step;\r\n" code_html += "}\r\n" code_html += "else {\r\n" code_html += "xPos = xPos - step;\r\n" code_html += "}\r\n" code_html += "if (xPos < 0) {\r\n" code_html += "xon = 1;\r\n" code_html += "xPos = 0;\r\n" code_html += "}\r\n" code_html += "if (xPos >= (width - Woffset)) {\r\n" code_html += "xon = 0;\r\n" code_html += "xPos = (width - Woffset);\r\n" code_html += "}\r\n" code_html += "}\r\n" code_html +="function start() {\r\n" code_html +="img.visibility = 'visible';\r\n" code_html +="interval = setInterval('changePos()', delay);\r\n" code_html +="}\r\n" code_html +="function mystop()\r\n" code_html +="{\r\n" code_html +="clearInterval(interval)\r\n" code_html +="}\r\n start()\r\n<\/script>" form_name.code.value = div_html + code_html; } function isNumber(value) { var desc = "0123456789"; for (var i = 0; i<value.length;i++) { if (desc.indexOf(value.charAt(i)) == -1) return false } return true; } --> </script> </head> <body topmargin="0"> <p><font size="4">图片flash随机飘动代码生成器 </font></p> <form name="createCode" method="post" action=""> <table width="700" border="0" cellspacing="0" cellpadding="0" style="line-height:20px"> <tr> <td width="119"> </td> <td width="256"> </td> <td colspan="4"> </td> </tr> <tr> <td width="119" align="right">飘动元素:</td> <td width="256"><input name="type" type="radio" value="image" checked onClick="fn_display(createCode.type)"> 图片文件<input type="radio" name="type" value="flash" onClick="fn_display(createCode.type)"> flash文件 </td> <td colspan="4"> </td> </tr> <tr id="image" style="display:"> <td align="right" >图片路径:</td> <td align="center"> <input type="text" name="imgPath" style="width:250px"></td> <td width="60" align="right">图片高度</td> <td width="92" align="center"><input type="text" name="imgHeight" style="width:80px"></td> <td width="67" align="right">图片宽度</td> <td width="106" align="center"><input type="text" name="imgWidth" style="width:80px"></td> </tr> <tr id="flash" style="display:none"> <td align="right">flash路径:</td> <td align="center"> <input type="text" name="fPath" style="width:250px"></td> <td width="60" align="right">flash高度</td> <td width="92" align="center"><input type="text" name="fHeight" style="width:80px"></td> <td width="67" align="right">flash宽度</td> <td width="106" align="center"><input type="text" name="fWidth" style="width:80px"></td> </tr> <tr id="imageUrl" style="display:"> <td align="right">图片链接:</td> <td align="center"> <input type="text" name="imgUrl" style="width:250px"></td> <td colspan="4" align="right"> </td> </tr> <tr> <td height="16" align="right">图片首次出现位置:</td> <td colspan="5"><input name="imgPosition" type="radio" value="topLeft" checked> 上左 <input type="radio" name="imgPosition" value="topCenter"> 上中 <input type="radio" name="imgPosition" value="topRight"> 上右 <input type="radio" name="imgPosition" value="bottomLeft"> 下左 <input type="radio" name="imgPosition" value="bottomCenter"> 下中 <input type="radio" name="imgPosition" value="bottomRight"> 下右 </td> </tr> <tr> <td align="right">图片飘动延迟时间:</td> <td colspan="5"><input type="radio" name="delay" value="5"> 5ms <input name="delay" type="radio" value="10" checked> 10ms <input type="radio" name="delay" value="20"> 20ms <input type="radio" name="delay" value="30"> 30ms <input type="radio" name="delay" value="40"> 40ms <input type="radio" name="delay" value="50"> 50ms</td> </tr> <tr> <td align="right" valign="top">鼠标事件:</td> <td align="left" valign="top"><input name="mouse" type="radio" value="1" checked> 是 <input type="radio" name="mouse" value="0"> 否 </td> <td colspan="4" align="left" valign="top">鼠标事件说明:<br>当鼠标放在图片上时,图片飘动是否停止</td> </tr> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"><input type="button" name="Button" value="生成代码" onClick="fn_createCode(createCode)"></td> <td colspan="4" align="left" valign="top"> </td> </tr> </table> <table width="700" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="81"> </td> <td width="626"><textarea name="code" cols="70" rows="15"></textarea></td> <td width="71"> </td> </tr> <tr> <td> </td> <td><input type="button" name="Button" value="复制到剪切板" onClick="JM_cc(code)"></td> <td> </td> </tr> <tr> <td> </td> <td>将文本框中生成的代码拷贝到您的页面</td> <td> </td> </tr> </table> </form> <p><font size="4"></font> </p> </body> </html>
提示:您可以先修改部分代码再运行
最大的爱好是帮助别人,最遗憾的是实在帮不上别人
积分
645
阅读权限
1
在线时间
0 小时
注册时间
2004-10-8
最后登录
2005-1-7
查看详细资料
TOP
广州周立功诚聘—平面/网页/UI/工业设计师
|
天业互联-酷睿租用599¥
pumaboyd
pumaboyd
初级会员
帖子
23
体力
68
威望
0
当前
上海 宝山
离线
249 天
个人网站
发短消息
加为好友
3
#
大
中
小
发表于 2005-1-4 14:59
可惜只可以设置一张图片随机,是否有可以生成多张图片随机的代码!!!
www.pumaboyd.com
积分
68
阅读权限
20
在线时间
9 小时
注册时间
2004-10-13
最后登录
2008-10-28
查看个人网站
查看详细资料
TOP
认证您的手机
,获得手机认证图标
, 更多
手机认证的好处
huangzhenpai
新手上路
帖子
4
体力
14
威望
0
离线
1431 天
发短消息
加为好友
4
#
大
中
小
发表于 2005-8-3 16:48
干吗要设那么多张 呢,满屏幕的跑,乱!
积分
14
阅读权限
10
在线时间
0 小时
注册时间
2005-8-3
最后登录
2005-8-3
查看详细资料
TOP
用CSS布局建站从零开始
|
Photoshop中打造史诗般梦幻场景
|
05年第一次软件行业创业的惨痛教训
zm8111
新手上路
帖子
3
体力
11
威望
0
离线
1429 天
发短消息
加为好友
5
#
大
中
小
发表于 2005-8-3 17:22
yun
积分
11
阅读权限
10
在线时间
0 小时
注册时间
2005-8-3
最后登录
2005-8-5
查看详细资料
TOP
lee191
高级会员
帖子
158
体力
565
威望
0
离线
430 天
个人网站
发短消息
加为好友
6
#
大
中
小
发表于 2005-8-3 18:24
强!!!!
积分
565
阅读权限
50
在线时间
22 小时
注册时间
2005-3-23
最后登录
2008-4-30
查看个人网站
查看详细资料
TOP
‹‹ 上一主题
|
下一主题 ››
版块跳转
内部交流区
网站开发区
前台制作与脚本专栏
后台数据库编程
WEB标准化专栏
WAP 技术专栏
平面设计区
艺术与设计论坛
Adobe Photoshop 专栏
Fireworks 专栏
矢量图形专栏
插画手绘交流
交互设计区
用户体验综合版
UI图形设计
RIA设计与应用
Flash 专栏
Silverlight 专版
Director 专栏
其它技术讨论区
计算机技术
英语学习和技术翻译
摄影欣赏与技术交流
无线通讯与数码设备
信息平台
企业招聘
学习工作交流区
体育运动、线下活动与游戏
创业版