<!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><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.ZoomIn.disabled = false;
fmImgZoom.ZoomOut.disabled = false;
fmImgZoom.Original.disabled = false;
fmImgZoom.FitScreen.disabled = false;
fmImgZoom.btnView.disabled = false;
fmImgZoom.btnImgInfo.disabled = false;
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);
}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.zoom>0.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()" disabled>
<input type="button" name="ZoomOut" value="ZoomOut" onclick="fnZoomOut()" disabled>
<input type="button" name="Original" value="Original" onclick="setOriginal()" disabled>
<input type="button" name="FitScreen" value="FitScreen" onclick="setFitScreen()" disabled>
<input type="button" name="btnView" value="hide/view" onclick="setDisplay()" disabled>
<input id="btnImgInfo" size="50" disabled>
</TD>
</TR>
</TABLE>
<div id="divMain" class="DivMain" onmousedown="fnDivMouseDown()">
<img src="22.jpg" id="imgMain" class="imgMain" onload="setInit(this)" onmousedown="fnMouseDown(this)" onmousemove="fnMouseMove()" onmouseup="fnMouseUp()" ></div>
<div id="divMenu" class="DivMenu" style="visibility:hidden"" onmousedown="fnMouseDown(this)" onmousemove="fnMouseMove()" onmouseup="fnMouseUp()" >
<TABLE class="TBMenu">
<TR>
<TD>10%</TD>
<TD><button id="HrScroll" class="HrScroll"><hr noshade></button> </TD>
<TD>1600%</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>
<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><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.ZoomIn.disabled = false;
fmImgZoom.ZoomOut.disabled = false;
fmImgZoom.Original.disabled = false;
fmImgZoom.FitScreen.disabled = false;
fmImgZoom.btnView.disabled = false;
fmImgZoom.btnImgInfo.disabled = false;
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);
}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.zoom>0.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()" disabled>
<input type="button" name="ZoomOut" value="ZoomOut" onclick="fnZoomOut()" disabled>
<input type="button" name="Original" value="Original" onclick="setOriginal()" disabled>
<input type="button" name="FitScreen" value="FitScreen" onclick="setFitScreen()" disabled>
<input type="button" name="btnView" value="hide/view" onclick="setDisplay()" disabled>
<input id="btnImgInfo" size="50" disabled>
</TD>
</TR>
</TABLE>
<div id="divMain" class="DivMain" onmousedown="fnDivMouseDown()">
<img src="22.jpg" id="imgMain" class="imgMain" onload="setInit(this)" onmousedown="fnMouseDown(this)" onmousemove="fnMouseMove()" onmouseup="fnMouseUp()" ></div>
<div id="divMenu" class="DivMenu" style="visibility:hidden"" onmousedown="fnMouseDown(this)" onmousemove="fnMouseMove()" onmouseup="fnMouseUp()" >
<TABLE class="TBMenu">
<TR>
<TD>10%</TD>
<TD><button id="HrScroll" class="HrScroll"><hr noshade></button> </TD>
<TD>1600%</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>
解决方案 »
- js 如何实现图片放大后图片中的某个位置始终在可视区域显示
- |zyciis| Jquery中的 $("[orgsrc]") 无效,是不是不支持自定义属性啊,谢谢
- 判断TextBox是否为空
- 使用自定义按键 Alt+A 触发自定义事件,但是事件执行后,会打开IE的菜单“收藏(A)”!,如何屏蔽IE的快捷键!
- 急死人的下拉框的问题,100分
- csdn左边tree一按叉就消失这种类形的,哪有类似而有十分好看的界面的网站,想抄一个回来用
- javascript问题
- 如和做到以个人为基准,一个人访问网站一次,统计浏览人数的计数器增一,而不是以页面刷新为准?(
- 请问如何实现判断输入的是纯数字,而不是含有数字的字符串?
- 选择器是变量,怎么获取其下某类元素?
- iframe子页面刷新的问题
- 请教javascript中类和对象的概念
xxx.style.visibility = "hidden";
}
else{
xxx.style.visibility = "";
}
}function setDisplay() { if(xxx.style.display== ""){
xxx.style.display= "none";
}
else{
xxx.style.visibility = "";
}
}
function setDisplay() { if(xxx.style.display== ""){
xxx.style.display= "none";
}
else{
xxx.style.display= "";
}
}
<div style="position: absolute; width: 100px; height: 100px; z-index: 2;display:none;" id="a1">
123</div>
<p> <script>
function chek()
{
if(document.getElementById("a1").style.display=="none")
document.getElementById("a1").style.display="";
else
document.getElementById("a1").style.display="none";
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title><script language="javascrip">
<!--
function textshow(){
//if(document.getElementById("Layer1").style.display=="none")
document.getElementById("Layer1").style.display="";
function texthide(){
//var obj=document.getElementById("Layer1");
//obj=obj.style;
//obj.display="";
//window.confirm("hide");
//if(document.getElementById("Layer1").style.display=="none")
// document.getElementById("Layer1").style.display="";
//else
document.getElementById("Layer1").style.display="none";}</script>
</head><body>
<div id="Layer1" align="center" style="position: absolute; width: 295px; height: 84px; z-index: 20; left: 271px; top: 64px; background-color: #999999; layer-background-color: #999999; border: 1px none #000000;display:none;"><span class="STYLE3">Hello,Welcome to my workspace!</span></div>
<button id="show" onclick="textshow()">show</button>
<button id="hide" onclick="texthide()">hide</button> </body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title><script language="javascrip">function textshow(){
//if(document.getElementById("Layer1").style.display=="none")
document.getElementById("Layer1").style.display="";
function texthide(){
//var obj=document.getElementById("Layer1");
//obj=obj.style;
//obj.display="";
//window.confirm("hide");
//if(document.getElementById("Layer1").style.display=="none")
// document.getElementById("Layer1").style.display="";
//else
document.getElementById("Layer1").style.display="none";}</script>
</head><body>
<button id="show" onclick="textshow()">show</button>
<button id="hide" onclick="texthide()">hide</button>
<div id="Layer1" align="center" style="position: absolute; width: 295px; height: 84px; z-index: 20; left: 271px; top: 64px; background-color: #999999; layer-background-color: #999999; border: 1px none #000000;"><span class="STYLE3">Hello,Welcome to my workspace!</span></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title><script language=javascript>
function textshow()
{
document.getElementById("Layer1").style.display="";
} function texthide(){
document.getElementById("Layer1").style.display="none";}</script>
</head><body>
<div id="Layer1" align="center" style="position: absolute; width: 295px; height: 84px; z-index: 20; left: 271px; top: 64px; background-color: #999999; layer-background-color: #999999; border: 1px none #000000;display:none;"><span class="STYLE3">
Hello,Welcome to my workspace!</span></div>
<button id="show" onclick="textshow()">show</button>
<button id="hide" onclick="texthide()">hide</button> </body>
</html>