关注图老师设计创意栏目可以让大家能更好的了解电脑,知道有关于电脑的更多有趣教程,今天给大家分享javascript模拟ACDSEE简单功能教程,希望对大家能有一点小小的帮助。
【 tulaoshi.com - Web开发 】
简单的放大缩小,显示坐标功能。
-------------------------------------
演示代码:
-------------------------------------
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
HTML
HEAD
TITLE Document /TITLE
style type="text/css"
body{
padding : 0px ;
margin : 0px;
background-color : #999999 ;
}
.DivMain {
position : absolute ;
text-align : center ;
overflow : hidden ;
}
.DivMenu {
position : absolute ;
text-align : left ;
overflow : hidden ;
}
.ImgMain {
position : absolute ;
overflow : hidden ;
border : 0px ;
}
.TBMain {
background-color : #CCCCCC ;
padding : 0px ;
border : 0px ;
z-index : 99 ;
line-height : 18px ;
}
.TBMenu {
background-color : #FFCCCC ;
padding : 0px ;
border : 0px ;
z-index : 99 ;
color: #000000 ;
}
.HrScroll {
margin : 0px;
background-color : #FFFFFF ;
padding : 0px ;
border : 0px ;
z-index : 99 ;
color : #000000 ;
border-spacing : 0px;
width : 160px ;
height : 10px ;
}
/style
objTbMain.style.top = 0;
objTbMain.style.height = 20;
objTbMain.style.width = intBodyWidth;
objDivMain.style.left = 0 ;
objDivMain.style.height = intBodyHeight - objTbMain.clientHeight;
objDivMain.style.width = intBodyWidth ;
initZoom(objCurrent);
}
intDivHeight = objDivMain.style.pixelHeight;
intObjHeight = obj.style.pixelHeight;
intZoomRatio = intDivHeight / intObjHeight;
obj.style.zoom = intZoomRatio ;
obj.style.top = 0;
obj.style.left = 0;
fnWritePos (obj.style.left,obj.style.top,obj.style.zoom) ;
}
function fnMouseDown(obj) {
ObjDrag=obj;
ObjDrag.setCapture();
ObjDrag.l=event.x-ObjDrag.style.pixelLeft;
ObjDrag.t=event.y-ObjDrag.style.pixelTop;
}
function fnMouseMove() {
if(ObjDrag!=null) {
ObjDrag.style.left = event.x-ObjDrag.l;
ObjDrag.style.top = event.y-ObjDrag.t;
fnWritePos(ObjDrag.style.left,ObjDrag.style.top,ObjDrag.style.zoom);
}
}
function fnMouseUp() {
if(ObjDrag!=null) {
ObjDrag.releaseCapture();
ObjDrag=null;
}
}
function fnZoomIn() {
objImg.style.zoom = parseFloat(objImg.style.zoom) + 0.01 ;
fnWritePos(objImg.style.left,objImg.style.top,objImg.style.zoom);
}
function fnZoomOut() {
if(objImg.style.zoom0.01){
objImg.style.zoom = parseFloat(objImg.style.zoom) - 0.01 ;
fnWritePos(objImg.style.left,objImg.style.top,objImg.style.zoom);
}
}
function fnDivMouseDown() {
if ( event.button == 2 && event.srcElement.id != "imgMain") {
objDivMenu.style.top = event.y;
objDivMenu.style.left = event.x;
objDivMenu.style.visibility = "";
oTextRange = objHrScroll.createTextRange() ;
oRcts = oTextRange.getClientRects();
oBndRct = objDivFlag.getBoundingClientRect();
objDivFlag.style.top = oRcts[0].top;
objDivFlag.style.left = oRcts[0].left + parseInt(objImg.style.zoom * 10) ;
objDivFlag.style.visibility = "";
}
if ( event.button == 1 && event.srcElement.id != "imgMain") {
objDivMenu.style.visibility = "hidden";
objDivFlag.style.visibility = "hidden";
}
}
function setDisplay() {
if(objImg.style.visibility == ""){
objImg.style.visibility = "hidden";
}
else{
objImg.style.visibility = "";
}
}
function fnContextMenu() {
window.event.returnValue=false;
}
//--
/SCRIPT
/HEAD
BODY oncontextmenu="fnContextMenu()"
form name="fmImgZoom"
TABLE id="tbMain" class="TBMain"
TR
TD
input type="button" name="ZoomIn" value="ZoomIn" onclick="fnZoomIn()"
input type="button" name="ZoomOut" value="ZoomOut" onclick="fnZoomOut()"
input type="button" name="Original" value="Original" onclick="setOriginal()"
input type="button" name="FitScreen" value="FitScreen" onclick="setFitScreen()"
input type="button" name="btnView" value="hide/view" onclick="setDisplay()"
input id="btnImgInfo" size="50"
/TD
/TR
/TABLE
div id="divMain" class="DivMain" onmousedown="fnDivMouseDown()"img src="/Files/BeyondPic/jcwcj/2005-12/10/05121012244084441.jpg" id="imgMain" class="imgMain" onload="setInit(this)" onmousedown="fnMouseDown(this)" onmousemove="fnMouseMove()" onmouseup="fnMouseUp()" /div
div id="divMenu" class="DivMenu" style="visibility:hidden"
TABLE class="TBMenu"
TR
TD10%/TD
TDbutton id="HrScroll" class="HrScroll"hr noshade/button /TD
TD1600%/TD
/TR
/TABLE
/div
DIV ID="DivFlag" STYLE="position:absolute;visibility:hidden;width:1px;height:10px;z-index:99" onmousedown="fnSlipMouseDown(this)" onmousemove="fnSlipMouseMove()" onmouseup="fnSlipMouseUp()" onmouseover="this.style.cursor ='hand'" onmouseout="this.style.cursor=''"↑/DIV
/form
/BODY
/HTML
来源:http://www.tulaoshi.com/n/20160219/1620004.html
看过《javascript模拟ACDSEE简单功能》的人还看了以下文章 更多>>