动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网页制作 > 网页特效
网页制作:Dreamweaver教程,FrontPages教程,Javascript教程,HTML教程,CSS教程,心得技巧,DHTML教程,网页特效,Discuz!论坛
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ 网页特效 ]的信息

本月文章推荐
.Java Applet 编程技巧实例专辑-图.
.左侧的隐藏菜单,点击后显示下拉.
.能记事的万年历特效代码.
.用CSS制作的很不错的简洁的网页导.
.联动菜单的演示效果[网页特效].
.按钮保存页面.
.一个不错的跑着改变字体颜色的特.
.选择相应的数字可以实现页面转跳.
.礼花背景(一个非常经典的网页背景.
.跟随鼠标旋转七彩光环背景.
.点击按钮就可以实现自动向下或向.
.对input框的分组选择功能的实现[.
.判断是否输入完毕再激活提交按钮.
.一个假的页面载入效果代码(和真的.
.单击右键弹出一个对话框.
.网页特效:随浏览器滚动条移动的.
.字符的背景特效.
.用CSS区分浏览器Firefox、IE6、I.
.随机显示不同网页.
.从窗口右下脚弹出的仿QQ的提示框.

用按钮控制图片的滚动方向

发表日期:2007-12-21 |


<!-- 把下面代码加到<body>区域中 -->
 <table>
<tr><td style="padding: 5">
<div id="testDiv" style="border: buttonface 2 solid">
<img src="/img/200407091.jpg">
</div>
<script language="JScript">
function scroll(obj, oWidth, oHeight, direction, drag, zoom, speed)
{
var scrollDiv  = obj
var scrollContent = document.createElement("span")
scrollContent.style.position = "absolute"
scrollDiv.applyElement(scrollContent, "inside")
var displayWidth = (oWidth  != "auto" && oWidth ) ? oWidth  : scrollContent.offsetWidth  + parseInt(scrollDiv.currentStyle.borderRightWidth)
var displayHeight = (oHeight != "auto" && oHeight) ? oHeight : scrollContent.offsetHeight + parseInt(scrollDiv.currentStyle.borderBottomWidth)
var contentWidth = scrollContent.offsetWidth
var contentHeight = scrollContent.offsetHeight
var scrollXItems = Math.ceil(displayWidth  / contentWidth)  + 1
var scrollYItems = Math.ceil(displayHeight / contentHeight) + 1

scrollDiv.style.width  = displayWidth
scrollDiv.style.height  = displayHeight
scrollDiv.style.overflow = "hidden"
scrollDiv.setAttribute("state", "stop")
scrollDiv.setAttribute("drag", drag ? drag : "horizontal")
scrollDiv.setAttribute("direction", direction ? direction : "left")
scrollDiv.setAttribute("zoom", zoom ? zoom : 1)
scrollContent.style.zoom = scrollDiv.zoom

var scroll_script = "var scrollDiv = " + scrollDiv.uniqueID          +"\n"+
"var scrollObj = " + scrollContent.uniqueID         +"\n"+
"var contentWidth = " + contentWidth + " * (scrollObj.runtimeStyle.zoom ? scrollObj.runtimeStyle.zoom : 1)" +"\n"+
"var contentHeight = " + contentHeight + " * (scrollObj.runtimeStyle.zoom ? scrollObj.runtimeStyle.zoom : 1)" +"\n"+
"var scrollx = scrollObj.runtimeStyle.pixelLeft"        +"\n"+
"var scrolly = scrollObj.runtimeStyle.pixelTop"         +"\n"+

"switch (scrollDiv.state.toLowerCase())"        +"\n"+
"{"             +"\n"+
"case ('scroll') :"         +"\n"+
"switch (scrollDiv.direction)"        +"\n"+
"{"           +"\n"+
"case ('left')  :"       +"\n"+
"scrollx = (--scrollx) % contentWidth"     +"\n"+
"break"         +"\n"+
"case ('right') :"        +"\n"+
"scrollx = -contentWidth + (++scrollx) % contentWidth"   +"\n"+
"break"         +"\n"+
"case ('up') :"        +"\n"+
"scrolly = (--scrolly) % contentHeight"     +"\n"+
"break"         +"\n"+
"case ('down') :"        +"\n"+
"scrolly = -contentHeight + (++scrolly) % contentHeight"  +"\n"+
"break"         +"\n"+
"case ('left_up') :"       +"\n"+
"scrollx = (--scrollx) % contentWidth"     +"\n"+
"scrolly = (--scrolly) % contentHeight"     +"\n"+
"break"         +"\n"+
"case ('left_down') :"       +"\n"+
"scrollx = (--scrollx) % contentWidth"     +"\n"+
"scrolly = -contentHeight + (++scrolly) % contentHeight"  +"\n"+
"break"         +"\n"+
"case ('right_up') :"       +"\n"+
"scrollx = -contentWidth + (++scrollx) % contentWidth"   +"\n"+
"scrolly = (--scrolly) % contentHeight"     +"\n"+
"break"         +"\n"+
"case ('right_down') :"       +"\n"+
"scrollx = -contentWidth + (++scrollx) % contentWidth"   +"\n"+
"scrolly = -contentHeight + (++scrolly) % contentHeight"  +"\n"+
"break"         +"\n"+
"default  :"       +"\n"+
"return"        +"\n"+
"}"           +"\n"+
"scrollObj.runtimeStyle.left = scrollx"       +"\n"+
"scrollObj.runtimeStyle.top = scrolly"       +"\n"+
"break"           +"\n"+

"case ('stop') :"          +"\n"+
"case ('drag') :"          +"\n"+
"default :"          +"\n"+
"return"          +"\n"+
"}"

var contentNode = document.createElement("span")
contentNode.runtimeStyle.position = "absolute"
contentNode.runtimeStyle.width = contentWidth
scrollContent.applyElement(contentNode, "inside")
for (var i=0; i <= scrollXItems; i++)
{
for (var j=0; j <= scrollYItems ; j++)
{
if (i+j == 0) continue
var tempNode = contentNode.cloneNode(true)
var contentLeft, contentTop
scrollContent.insertBefore(tempNode)
contentLeft = contentWidth * i
contentTop = contentHeight * j
tempNode.runtimeStyle.left = contentLeft
tempNode.runtimeStyle.top  = contentTop
}
}

scrollDiv.onpropertychange = function()
{
var propertyName = window.event.propertyName
var propertyValue = eval("this." + propertyName)

switch(propertyName)
{
case "zoom"  :
var scrollObj = this.children[0]
scrollObj.runtimeStyle.zoom = propertyValue
var content_width  = scrollObj.children[0].offsetWidth  * propertyValue
var content_height = scrollObj.children[0].offsetHeight * propertyValue
scrollObj.runtimeStyle.left = -content_width  + (scrollObj.runtimeStyle.pixelLeft % content_width)
scrollObj.runtimeStyle.top  = -content_height + (scrollObj.runtimeStyle.pixelTop  % content_height)
break
}
}

scrollDiv.onlosecapture = function()
{
this.state = this.tempState ? this.tempState : this.state
this.runtimeStyle.cursor = ""
this.removeAttribute("tempState")
this.removeAttribute("start_x")
this.removeAttribute("start_y")
this.removeAttribute("default_left")
this.removeAttribute("default_top")
}

scrollDiv.onmousedown = function()
{
if (this.state != "drag") this.setAttribute("tempState", this.state)
this.state = "drag"
this.runtimeStyle.cursor = "default"
this.setAttribute("start_x", event.clientX)
this.setAttribute("start_y", event.clientY)
this.setAttribute("default_left", this.children[0].style.pixelLeft)
this.setAttribute("default_top", this.children[0].style.pixelTop)
this.setCapture()
}

scrollDiv.onmousemove = function()
{
if (this.state != "drag") return
var scrollx = scrolly = 0
var zoomValue = this.children[0].style.zoom ? this.children[0].style.zoom : 1
var content_width = this.children[0].children[0].offsetWidth * zoomValue
var content_Height = this.children[0].children[0].offsetHeight * zoomValue
if (this.drag == "horizontal" || this.drag == "both")
{
scrollx = this.default_left + event.clientX - this.start_x
scrollx = -content_width + scrollx % content_width
this.children[0].runtimeStyle.left = scrollx
}
if (this.drag == "vertical" || this.drag == "both")
{
scrolly = this.default_top + event.clientY - this.start_y
scrolly = -content_Height + scrolly % content_Height
this.children[0].runtimeStyle.top = scrolly
}
}

scrollDiv.onmouseup = function()
{
this.releaseCapture()
}

scrollDiv.state = "scroll"
setInterval(scroll_script, speed ? speed : 20)
}
</script>
<script language="JScript">
window.onload = new Function("scroll(document.all['testDiv'], 325)")
</script>
<br>
<button onclick="testDiv.direction='up'; testDiv.state='scroll'"><span style="font-family: Webdings">5</span>向上</button>
<button onclick="testDiv.direction='left'; testDiv.state='scroll'"><span style="font-family: Webdings">3</span>向左</button>
<button onclick="testDiv.state='stop'"><span style="font-family: Webdings">;</span>停止</button>
<button onclick="testDiv.state='scroll'"><span style="font-family: Webdings">8</span>播放</button>
<button onclick="testDiv.direction='right'; testDiv.state='scroll'"><span style="font-family: Webdings">4</span>向右</button>
<button onclick="testDiv.direction='down'; testDiv.state='scroll'"><span style="font-family: Webdings">6</span>向下</button>
<br>
缩放:
<select onchange="testDiv.zoom = this.options[selectedIndex].value">
<option value=1>100%</option>
<option value=2>200%</option>
<option value=3>300%</option>
</select>     
托动范围:
<select onchange="testDiv.drag = this.options[selectedIndex].value">
<option value="both">随意</option>
<option value="horizontal" selected>横向</option>
<option value="vertical">纵向</option>
</select>
</td></tr>
</table>

上一篇:页面背景花瓣效果 人气:712
下一篇:桌面图标的排列,体现wingdings字体的超强功能 人气:779
浏览全部javascript的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 HDWiki v4.0.1 bulid 081007 UTF
2008-10-7 迅易评选投票管理系统 v10.0
2008-10-7 HDWiki v4.0.1 bulid 081007 GBK
2008-10-7 Bitrac单用户博客 v1.14 bulid 0
2008-10-7 OpenX(广告管理系统) v2.6.2 多国
2008-10-7 乐铺网店系统免费普及版 v3.41
2008-9-29 酷狗音乐(原KuGoo)2008 v5.310 正
2008-9-29 QQTab 1.1
2008-9-29 网络传送带 Net Transport 2.64a
2008-9-29 谷歌金山词霸v1.8
2008-9-29 TweakVI 1.0 Build 1090
2008-9-29 ACDSee Pro 2.5 Build 333 汉化绿
2008-9-29 Winamp v5.541(2189) 周明波简体
2008-9-27 CCleaner 2.12.651
2008-9-27 Mozilla Thunderbird 2.0.0.17 英
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | js/vbs加密 | md5加密 | 进制转换 | UTF-8 转换工具 | Html转换js | Html转换asp | Html转换php | Html转换perl
实用工具:汉字翻译拼音 | 拼音字典 | 符号对照表 | 个税计算 | 实时汇率查询换算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 | 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号