会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
Try again
博客园
首页
联系
管理
Javascript, How to make a Dress Up Game (Drag and Drop)
<
style
>
<!--
.dragme
{position:relative;}
-->
</
style
>
<
script language
=
"
JavaScript1.2
"
>
<!--
var
ie
=
document.all;
var
nn6
=
document.getElementById
&&!
document.all;
var
isdrag
=
false
;
var
x,y;
var
dobj;
function
movemouse(e)
{
if
(isdrag)
{
dobj.style.left
=
nn6
?
tx
+
e.clientX
-
x : tx
+
event.clientX
-
x;
dobj.style.top
=
nn6
?
ty
+
e.clientY
-
y : ty
+
event.clientY
-
y;
return
false
;
}
}
function
selectmouse(e)
{
var
fobj
=
nn6
?
e.target : event.srcElement;
var
topelement
=
nn6
?
"
HTML
"
:
"
BODY
"
;
while
(fobj.tagName
!=
topelement
&&
fobj.className
!=
"
dragme
"
)
{
fobj
=
nn6
?
fobj.parentNode : fobj.parentElement;
}
if
(fobj.className
==
"
dragme
"
)
{
isdrag
=
true
;
dobj
=
fobj;
tx
=
parseInt(dobj.style.left
+
0
);
ty
=
parseInt(dobj.style.top
+
0
);
x
=
nn6
?
e.clientX : event.clientX;
y
=
nn6
?
e.clientY : event.clientY;
document.onmousemove
=
movemouse;
return
false
;
}
}
document.onmousedown
=
selectmouse;
document.onmouseup
=
new
Function(
"
isdrag=false
"
);
//
-->
</
script
>
<
img src
=
"
ttt.jpg
"
class
=
"
dragme
"
>
JSON(
http://www.json.org/json-zh.html
)
<
script
>
var
myJSONObject
=
{
"
bindings
"
:
[
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
newURI
"
,
"
regex
"
:
"
^http://.*
"
}
,
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
deleteURI
"
,
"
regex
"
:
"
^delete.*
"
}
,
{
"
ircEvent
"
:
"
PRIVMSG
"
,
"
method
"
:
"
randomURI
"
,
"
regex
"
:
"
^random.*
"
}
]
}
;
alert(myJSONObject.bindings[
0
].method);
//
"newURI"
</
script
>
posted on
2006-11-16 19:47
共同学习,共同进步
阅读(
473
) 评论(
1
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 共同学习,共同进步
Powered by .NET 8.0 on Kubernetes