网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 网络学院 >> 程序设计 >> Java编程 >> 文章正文
  javascript图片浏览代码 实用            【字体:
javascript图片浏览代码 实用
作者:佚名    文章来源:不详    点击数:    更新时间:2007-9-2    
正在装载数据……

1.将下面的代码复制到<head>内

<script>

/*
Thumbnail image viewer-
?Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/


function enlarge(which,e){
//Render image code for IE 4+
if (document.all){
if (showimage.style.visibility=="hidden"){
showimage.style.left=document.body.scrollLeft+event.clientX
showimage.style.top=document.body.scrollTop+event.clientY
showimage.innerHTML='<img src="'+which+'">'
showimage.style.visibility="visible"
}
else
showimage.style.visibility="hidden"
return false
}
//Render image code for NS 4
else if (document.layers){
if (document.showimage.visibility=="hide"){
document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="'+which+'" border=0></a>')
document.showimage.document.close()
document.showimage.left=e.x
document.showimage.top=e.y
document.showimage.visibility="show"
}
else
document.showimage.visibility="hide"
return false
}
//if NOT IE 4+ or NS 4, simply display image in full browser window
else
return true
}


</script>


<script language="JavaScript1.2">

//By Dynamicdrive.com

//drag drop function for NS 4////
/////////////////////////////////

var nsx
var nsy
var nstemp

function drag_dropns(name){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for IE 4+////
/////////////////////////////////

var dragapproved=false

function drag_dropie(){
if (dragapproved==true){
document.all.showimage.style.pixelLeft=tempx+event.clientX-iex
document.all.showimage.style.pixelTop=tempy+event.clientY-iey
return false
}
}

function initializedragie(){
if (event.srcElement.parentElement.id=="showimage"){
iex=event.clientX
iey=event.clientY
tempx=showimage.style.pixelLeft
tempy=showimage.style.pixelTop
dragapproved=true
document.onmousemove=drag_dropie
}
}

if (document.all){
document.onmousedown=initializedragie
document.onmouseup=new Function("dragapproved=false")
}


</script>

2.在<body>中加入
<div id="showimage" style="position:absolute;visibility:hidden"></div>

3.在连接图片的地方这样写.
<a href="photo1.jpg" onClick="return enlarge('photo1.jpg',event)"><img src="thumbnail.gif" border="0"></a>

更改图片路径 




本文来源:http://blog.csdn.net/ITshu/archive/2007/08/21/1753405.aspx
站内文章搜索 高级搜索
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
     用java实现web服务器
     用java快速开发linux gu…
     正则表达式分解siemens交…
     [portal参考手册]目录
     jsp中调用oracle存储过程…
  • JSP中JavaBean的生命周期

  • Java Swing实现俄罗斯方块

  • java异常处理机制的深入理解

  • [转]Java堆和栈的区别 经典总…

  • 关于java Applet

  • java 设计工厂模式

  • Core Java 之旅

  • 专访Java之父:Java未来的发…

  • 开发手记---JAVA数据库连接池

  • [ZT]彻底搞定java文件上传zz

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    网络学院©2007 www.23book.net
    为您提供web编程,vb编程,vc编程,服务器架设管理,数据库设计等方面的知识 站长:David