网站首页
cms
asp
php
jsp
asp.net
数据库
web前端
服务器
javascript
c#
vb.net
java
linux
office
数据结构
其他语言
网络安全
电脑故障
电脑故障
位置:
IT落伍者
>>
电脑故障
>> 浏览文章
给地图找个放大镜
发布日期:2023/11/13
<html>
<head><meta http
equiv="Content
Type" content="text/html; charset=gb
"><title>网页特效观止|www
jscode
cn|
给地图加个放大镜</title><SCRIPT>var shrinkfactor=
// left and top position of the thumbnailimage// (distance to the left and top browser
margin
pixels)var thumbleft =
var thumbtop =
// left and top position of the zoomed image// (distance to the left and top browser
margin
pixels)var largeleft =
var largetop =
// width and height of the enlarged image
s sector (visible part
pixels)var clipwidth =
var clipheight =
</SCRIPT><SCRIPT>var isNav
isIEvar offsetX
offsetYvar selectedObjvar largewidth =
var largeheight =
var thumbwidth = Math
floor(largewidth/shrinkfactor)var thumbheight = Math
floor(largeheight/shrinkfactor)var dragimgwidth = Math
floor(clipwidth/shrinkfactor)var dragimgheight = Math
floor(clipheight/shrinkfactor)var dragimgleft = thumbleft+
var dragimgtop = thumbtop+
var difleft= largeleft
thumbleftvar diftop= largetop
thumbtopvar clippointsvar cliptop=
var clipbottom=cliptop+clipheightvar clipleft=
var clipright=clipleft+clipwidthif (parseInt(navigator
appVersion) >=
) {if (navigator
appName == "Netscape") {isNav = true} else {isIE = true}}function setZIndex(obj
zOrder) {obj
zIndex = zOrder}function shiftTo(obj
x
y) {if (isNav) { if(x<=document
thumb
left) {x=document
thumb
left}if(x>=(document
thumb
left+thumbwidth
dragimgwidth
)) {x=document
thumb
left+thumbwidth
dragimgwidth
}if(y<=document
thumb
top) {y=document
thumb
top}if(y>=(document
thumb
top+thumbheight
dragimgheight
)) {y=document
thumb
top+thumbheight
dragimgheight
}obj
moveTo(x
y)} else {if(x<=document
all
thumb
style
posLeft) {x=document
all
thumb
style
posLeft}if(x>=(document
all
thumb
style
posLeft+thumbwidth
dragimgwidth
)) {x=document
all
thumb
style
posLeft+thumbwidth
dragimgwidth
}if(y<=document
all
thumb
style
posTop) {y=document
all
thumb
style
posTop}if(y>=(document
all
thumb
style
posTop+thumbheight
dragimgheight
)) {y=document
all
thumb
style
posTop+thumbheight
dragimgheight
}obj
pixelLeft = xobj
pixelTop = y}cliptop = (y
thumbtop)*shrinkfactorclipbottom = cliptop+clipheightclipleft = (x
thumbleft)*shrinkfactorclipright = clipleft+clipwidthif (document
all) {clippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"document
all
large
style
posTop=largetop
cliptopdocument
all
large
style
posLeft=largeleft
clipleftdocument
all
large
style
clip=clippoints}if (document
layers) {document
large
top=largetop
cliptopdocument
large
left=largeleft
clipleftdocument
large
clip
left = clipleftdocument
large
clip
right = cliprightdocument
large
clip
top = cliptopdocument
large
clip
bottom = clipbottom}}function setSelectedElem(evt) {if (isNav) {var testObjvar clickX = evt
pageXvar clickY = evt
pageYfor (var i = document
layers
length
; i >=
; i
) {testObj = document
layers[i]if ((clickX > testObj
left) &&(clickX < testObj
left + testObj
clip
width) &&(clickY > testObj
top) &&(clickY < testObj
top + testObj
clip
height && document
layers[i]
id=="dragimg")) {selectedObj = testObjsetZIndex(selectedObj
)return}}} else {var imgObj = window
event
srcElementif (imgObj
parentElement
id
indexOf("dragimg") !=
) {selectedObj = imgObj
parentElement
stylesetZIndex(selectedObj
)return}}selectedObj = nullreturn}function dragIt(evt) {if (selectedObj) {if (isNav) {shiftTo(selectedObj
(evt
pageX
offsetX)
(evt
pageY
offsetY))} else {shiftTo(selectedObj
(window
event
clientX
offsetX)
(window
event
clientY
offsetY))return false}}}function engage(evt) {setSelectedElem(evt)if (selectedObj) {if (isNav) {offsetX = evt
pageX
selectedObj
leftoffsetY = evt
pageY
selectedObj
top} else {offsetX = window
event
offsetXoffsetY = window
event
offsetY}}return false}function release(evt) {if (selectedObj) {setZIndex(selectedObj
)selectedObj = null}}function setNavEventCapture() {if (isNav) {document
captureEvents(Event
MOUSEDOWN | Event
MOUSEMOVE | Event
MOUSEUP)}}function init() {if (document
layers) { var imageurl=document
large
document
largepic
src largewidth=document
large
document
widthlargeheight=document
large
document
heightthumbwidth = Math
floor(largewidth/shrinkfactor)thumbheight = Math
floor(largeheight/shrinkfactor) document
thumb
document
write("<IMG NAME=
thumbpic
SRC=
"+imageurl+"
width="+thumbwidth+" height="+thumbheight+">") document
thumb
document
close()document
dragimg
document
write("<IMG NAME=
dragimgpic
border=
SRC=
dragimg
gif
width="+dragimgwidth+" height="+dragimgheight+">") document
dragimg
document
close()document
large
left=largeleftdocument
large
top=largetopdocument
thumb
left=thumbleftdocument
thumb
top=thumbtopdocument
dragimg
left=dragimgleftdocument
dragimg
top=dragimgtopdocument
large
clip
left=clipleftdocument
large
clip
right=cliprightdocument
large
clip
top=cliptopdocument
large
clip
bottom=clipbottomdocument
large
visibility="visible"setNavEventCapture()}if (document
all) { var imageurl=document
largepic
srclargewidth=document
all
large
offsetWidthlargeheight=document
all
large
offsetHeightthumbwidth = Math
floor(largewidth/shrinkfactor)thumbheight = Math
floor(largeheight/shrinkfactor)thumb
innerHTML="<IMG NAME=
thumbpic
SRC=
"+imageurl+"
width="+thumbwidth+" height="+thumbheight+">"dragimg
innerHTML="<IMG NAME=
dragimgpic
border=
SRC=
width="+dragimgwidth+" height="+dragimgheight+">"document
all
large
style
posLeft=largeleftdocument
all
large
style
posTop=largetopdocument
all
thumb
style
posLeft=thumbleftdocument
all
thumb
style
posTop=thumbtopdocument
all
dragimg
style
posLeft=dragimgleftdocument
all
dragimg
style
posTop=dragimgtopclippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"document
all
large
style
clip=clippointsdocument
all
large
style
visibility="visible"}document
onmousedown = engagedocument
onmousemove = dragItdocument
onmouseup = release}window
onload=init</SCRIPT></head><body><p>用鼠标移动下面的方框
效果不错吧</p><center><DIV style="position:absolute;visibility:hidden;" ID="large"><IMG NAME="largepic" SRC="<DIV style="position:absolute;" ID="thumb"></DIV><DIV style="position:absolute;" ID="dragimg"></DIV></center></body></html>
上一篇:
选择器中含有空格在使用示例及注意事项
下一篇:
只能输入汉字