|
|
 
 
|
|
帖子排序:
|
|
|
|
|
帖子发起人: 大哥 发起时间: 2006-08-31 21:58 下午 回复: 1
|
大哥


注册: 2006-01-21
发 贴: 57
|
|
|
源代码如下:
图片随意移动
#plane1 {position:absolute; left:290; top:170; width:121; z-index:0}
#plane2 {position:absolute; left:400; top:250; width:118; z-index:0}
//Modified by the CoffeeCup HTML Editor++
//http://www.coffeecup.com
// Global variables for platform branching
var isNav, isIE
if (parseInt(navigator.appVersion) >= 4) {
if (navigator.appName == "Netscape") {
isNav = true
} else {
isIE = true
}
}
// ***Begin CSS custom API Functions***
// Set zIndex property
function setZIndex(obj, zOrder) {
obj.zIndex = zOrder
}
// Position an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
if (isNav) {
obj.moveTo(x,y)
} else {
obj.pixelLeft = x
obj.pixelTop = y
}
}
// ***End API Functions***
// Global holds reference to selected element
var selectedObj
// Globals hold location of click relative to element
var offsetX, offsetY
// Find out which element has been clicked on
function setSelectedElem(evt) {
if (isNav) {
// declare local var for use in upcoming loop
var testObj
// make copies of event coords for use in upcoming loop
var clickX = evt.pageX
var clickY = evt.pageY
// loop through all layers (starting with frontmost layer)
// to find if the event coordinates are in the layer
for (var i = document.layers.length - 1; i >= 0; i--) {
testObj = document.layers<img src="/cs/emoticons/emotion-55.gif" alt="Idea [I]" />
if ((clickX > testObj.left) &&
(clickX testObj.top) &&
(clickY
<DIV ID=plane1><IMG SRC="clock1.gif" BORDER=0></DIV>
<DIV ID=plane2><IMG SRC="clock2.gif" BORDER=0></DIV>
很不错的哦!
|
|
|
IP 地址: 已记录
|
报告
|
|
時空逸夢

注册: 2006-05-01
安徽合肥
发 贴: 500
|
|
|
顶&***_)_)^%
|
|
|
IP 地址: 已记录
|
报告
|
|
|
合肥微软技术中心社区 » 技术讨论区 » .NET技术相关 » Re: Javascrip实现图片随意移动
|
|
|
|