javascript模拟ACDSEE简单功能

2016-02-19 19:06 10 1 收藏

关注图老师设计创意栏目可以让大家能更好的了解电脑,知道有关于电脑的更多有趣教程,今天给大家分享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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)SCRIPT LANGUAGE="JavaScript"
!--
 var originalWidth ;
 var originalHeight ;
 var objDivMain ;
 var objTbMain ;
 var objImg ;
 var ObjDrag ;
 var objDivMenu ;
 var objTbMemu ;
 var objbtnImgInfo ;
 var objDivFlag;
 var objHrScroll;
 var oRcts ;
 var oTextRange ; 
function setInit(obj) {
 objDivMain = document.getElementById("divMain") ;
 objTbMain =  document.getElementById("TbMain") ;
 objDivMenu = document.getElementById("DivMenu") ;
 objTbMenu =  document.getElementById("TbMenu") ;
 objImg = document.getElementById("imgMain") ;
 objbtnImgInfo = document.getElementById("btnImgInfo") ;
 
 objDivFlag = document.getElementById("DivFlag");
 objHrScroll = document.getElementById("HrScroll");
 originalWidth = obj.width;
 originalHeight = obj.height;
 objImg.style.width = originalWidth;
 objImg.style.height = originalHeight;
 fmImgZoom.FitScreen.click();
}
function setFitScreen() {
 initImg(objImg);
}
function setOriginal() {
 var intBodyWidth ;
 var intBodyHeight ;
 intBodyWidth = document.body.clientWidth ;
 intBodyHeight = document.body.clientHeight ;
 objImg.style.left = 0 ;
 objImg.style.top = 0 ;
 objImg.style.width = originalWidth;
 objImg.style.height = originalHeight;
 objImg.style.zoom = 1 ;
 objDivMain.style.width = intBodyWidth ;
 objDivMain.style.height = intBodyHeight - objTbMain.clientHeight;
 fnWritePos(objImg.style.left,objImg.style.top,objImg.style.zoom);
}
function initImg(objCurrent) {
 var intBodyWidth ;
 var intBodyHeight ;
 intBodyWidth = document.body.clientWidth ;
 intBodyHeight = document.body.clientHeight ;

 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);
}

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)function initZoom(obj){
 var intObjWidth ;
 var intObjHeight ;
 var intDivHeight ;
 var intZoomRatio ;

 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 fnWritePos(intLeft,intTop,intZoom) {
 objbtnImgInfo.innerText = " ImgLeft:" + intLeft + " ImgTop:" + intTop + " ImgZoom:" + intZoom ;
}
function fnSlipMouseDown(obj) {
 ObjDrag=obj;
 ObjDrag.setCapture();
 ObjDrag.l = event.x - ObjDrag.style.pixelLeft;
 ObjDrag.t = ObjDrag.style.pixelTop;
}
function fnSlipMouseMove() {
 if(ObjDrag!=null) {
  if(event.x = oRcts[0].left && event.x = oRcts[0].right ){
   ObjDrag.style.left = event.x - objDivFlag.offsetWidth / 2;
  }
  ObjDrag.t = ObjDrag.style.pixelTop;
  var intCurrentPos = ObjDrag.style.pixelLeft - oRcts[0].left + objDivFlag.offsetWidth / 2;
  var intPicZoom = intCurrentPos / 10;
  objImg.style.zoom = intPicZoom;
  fnWritePos(objImg.style.left,objImg.style.top,objImg.style.zoom);
 }
}
function fnSlipMouseUp() {
 if(ObjDrag!=null) {
  ObjDrag.releaseCapture();
  ObjDrag=null;
 }
}

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

来源:https://www.tulaoshi.com/n/20160219/1620004.html

延伸阅读
标签: Web开发
使用浏览器的内部对象系统, 可实现与HTML文档进行交互。它的作用是将相关元素组织包装起来,提供给程序设计人员使用,从而减轻编程人的劳动,提高设计Web页面的能力。 二、文档对象功能及其作用 在Navigator浏览器中,document文档对象是核心是,同时也是最重要的。见表6-1所示。 Links Anchor Form Method Prop 链接对象 ...
标签: Web开发
随着数码相机的普及,每次出游回来都会面对数量上百的照片整理,处理效率还是非常重要的因素。ACDSee 3.1(完整版)仍然是我目前最常用的照片查看/归档工具。以下是使用ACDSee进行照片整理和HTML相册生成的经验总结,大部分操作都可以完全只使用键盘操作完成。 照片汇总和批量重命名 可以先将所有的数码相机的照片汇总到一个目...
标签: Web开发
下面我们通过一个例子,编写第一个 JavaScript 程序。 通过它可说明JavaScript的脚本是怎样被嵌入到HTML文档中的。test1.html文档: html head Script Language ="JavaScript" // JavaScript Appears here. alert("这是第一个JavaScript例子!"); alert("欢迎你进入JavaScript世界!"); alert("今后...
标签: Web开发
当你创建了一个新窗口时,将open()方法的返回值分配给一个变量非常重要。比如,下面的语句就是创建一个新窗口,然后立即关闭它: win = window.open("http://www.docjs.com/", "js"); win.close(); 每一个浏览器窗口都清楚地与一个window对象对应,所以,当你想引用当前窗口时,你应该使用window对象。下面的语句设置当前窗...
标签: Web开发
代码如下: script language="javascript" /*Javascript中暂停功能的实现 Javascript本身没有暂停功能(sleep不能使用)同时 vbscript也不能使用doEvents,故编写此函数实现此功能。 javascript作为弱对象语言,一个函数也可以作为一个对象使用。 比如: function Test(){  alert("hellow");  this.NextStep=f...

经验教程

455

收藏

9
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部