南强小屋 Design By 杰米
复制代码 代码如下:
<!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">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<title>DoDi Chat v1.0 Beta</title>
<style rel="stylesheet" type="text/css" media="all" />
<!--
body {
text-align:left;
margin:0;
font:normal 12px Verdana, Arial;
background:#FFEEFF
}
form {
margin:0;
font:normal 12px Verdana, Arial;
}
table,input {
font:normal 12px Verdana, Arial;
}
a:link,a:visited{
text-decoration:none;
color:#333333;
}
a:hover{
text-decoration:none;
color:#FF6600
}
#main {
width:400px;
position:absolute;
left:600px;
top:100px;
background:#EFEFFF;
text-align:left;
filter:Alpha(opacity=90)
}
#ChatHead {
text-align:right;
padding:3px;
border:1px solid #003399;
background:#DCDCFF;
font-size:11px;
color:#3366FF;
cursor:move;
}
#ChatHead a:link,#ChatHead a:visited, {
font-size:14px;
font-weight:bold;
padding:0 3px
}
#ChatBody {
border:1px solid #003399;
border-top:none;
padding:2px;
}
#ChatContent {
height:200px;
padding:6px;
overflow-y:scroll;
word-break: break-all
}
#ChatBtn {
border-top:1px solid #003399;
padding:2px
}
-->
</style>
<script language="javascript" type="text/javascript">
<!--
function ChatHidden()
{
document.getElementById("ChatBody").style.display = "none";
}
function ChatShow()
{
document.getElementById("ChatBody").style.display = "";
}
function ChatClose()
{
document.getElementById("main").style.display = "none";
}
function ChatSend(obj)
{
var o = obj.ChatValue;
if (o.value.length>0){
document.getElementById("ChatContent").innerHTML += "<strong>Akon说:</strong>"+o.value+"<br/>";
o.value='';
}
}
if (document.getElementById)
{
(
function()
{
if (window.opera){ document.write("<input type='hidden' id='Q' value=' '>"); }
var n = 500;
var dragok = false;
var y,x,d,dy,dx;
function move(e)
{
if (!e) e = window.event;
if (dragok){
d.style.left = dx + e.clientX - x + "px";
d.style.top = dy + e.clientY - y + "px";
return false;
}
}
function down(e)
{
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if('TR'==temp.tagName){
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if (temp.className == "dragclass"){
if (window.opera){ document.getElementById("Q").focus(); }
dragok = true;
temp.style.zIndex = n++;
d = temp;
dx = parseInt(temp.style.left+0);
dy = parseInt(temp.style.top+0);
x = e.clientX;
y = e.clientY;
document.onmousemove = move;
return false;
}
}
function up(){
dragok = false;
document.onmousemove = null;
}
document.onmousedown = down;
document.onmouseup = up;
}
)();
}
-->
</script>
</head>
<body>
<div id="main" class="dragclass">
<div id="ChatHead">
<a href="#" onclick="ChatHidden();">-</a>
<a href="#" onclick="ChatShow();">+</a>
<a href="#" onclick="ChatClose();">x</a>
</div>
<div id="ChatBody">
<div id="ChatContent"></div>
<div id="ChatBtn">
<form action="" name="chat" method="post">
<textarea name="ChatValue" rows="3" style="width:350px"></textarea>
<input name="Submit" type="button" value="Chat" onclick="ChatSend(this.form);" />
</form>
</div>
</div>
</div>
</body>
</html>
一个拖动效果,根据论坛的一些帖子改的,但还有一些BUG一直没法解决,谁能帮我改改?
当第一次拖动层时,层的位置会偏离很远。
呃。。。这涉及到一个style的问题。。。
在ie和firefox中,obj.style这个东西实际上只是取得元素中属性style中的值!
如下例,你会发现style块中的属性一个都取不到!
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=t.style;
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
看到了没?前两个style 为空,后两个才有值。
如果是ie,问题很好解决,只要把style改成currentStyle即可。
IE Only
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=t.currentStyle;
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
FF only
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=document.defaultView.getComputedStyle(t, null);
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
我绕了半天,你明白你的错误原因了吗?你的style全都是文档级style,而你试图获取left的时候,第一次获得的只是0,自然会把你的框给挪到边上去了。
12下一页阅读全文
<!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">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<title>DoDi Chat v1.0 Beta</title>
<style rel="stylesheet" type="text/css" media="all" />
<!--
body {
text-align:left;
margin:0;
font:normal 12px Verdana, Arial;
background:#FFEEFF
}
form {
margin:0;
font:normal 12px Verdana, Arial;
}
table,input {
font:normal 12px Verdana, Arial;
}
a:link,a:visited{
text-decoration:none;
color:#333333;
}
a:hover{
text-decoration:none;
color:#FF6600
}
#main {
width:400px;
position:absolute;
left:600px;
top:100px;
background:#EFEFFF;
text-align:left;
filter:Alpha(opacity=90)
}
#ChatHead {
text-align:right;
padding:3px;
border:1px solid #003399;
background:#DCDCFF;
font-size:11px;
color:#3366FF;
cursor:move;
}
#ChatHead a:link,#ChatHead a:visited, {
font-size:14px;
font-weight:bold;
padding:0 3px
}
#ChatBody {
border:1px solid #003399;
border-top:none;
padding:2px;
}
#ChatContent {
height:200px;
padding:6px;
overflow-y:scroll;
word-break: break-all
}
#ChatBtn {
border-top:1px solid #003399;
padding:2px
}
-->
</style>
<script language="javascript" type="text/javascript">
<!--
function ChatHidden()
{
document.getElementById("ChatBody").style.display = "none";
}
function ChatShow()
{
document.getElementById("ChatBody").style.display = "";
}
function ChatClose()
{
document.getElementById("main").style.display = "none";
}
function ChatSend(obj)
{
var o = obj.ChatValue;
if (o.value.length>0){
document.getElementById("ChatContent").innerHTML += "<strong>Akon说:</strong>"+o.value+"<br/>";
o.value='';
}
}
if (document.getElementById)
{
(
function()
{
if (window.opera){ document.write("<input type='hidden' id='Q' value=' '>"); }
var n = 500;
var dragok = false;
var y,x,d,dy,dx;
function move(e)
{
if (!e) e = window.event;
if (dragok){
d.style.left = dx + e.clientX - x + "px";
d.style.top = dy + e.clientY - y + "px";
return false;
}
}
function down(e)
{
if (!e) e = window.event;
var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass"){
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if('TR'==temp.tagName){
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
}
if (temp.className == "dragclass"){
if (window.opera){ document.getElementById("Q").focus(); }
dragok = true;
temp.style.zIndex = n++;
d = temp;
dx = parseInt(temp.style.left+0);
dy = parseInt(temp.style.top+0);
x = e.clientX;
y = e.clientY;
document.onmousemove = move;
return false;
}
}
function up(){
dragok = false;
document.onmousemove = null;
}
document.onmousedown = down;
document.onmouseup = up;
}
)();
}
-->
</script>
</head>
<body>
<div id="main" class="dragclass">
<div id="ChatHead">
<a href="#" onclick="ChatHidden();">-</a>
<a href="#" onclick="ChatShow();">+</a>
<a href="#" onclick="ChatClose();">x</a>
</div>
<div id="ChatBody">
<div id="ChatContent"></div>
<div id="ChatBtn">
<form action="" name="chat" method="post">
<textarea name="ChatValue" rows="3" style="width:350px"></textarea>
<input name="Submit" type="button" value="Chat" onclick="ChatSend(this.form);" />
</form>
</div>
</div>
</div>
</body>
</html>
一个拖动效果,根据论坛的一些帖子改的,但还有一些BUG一直没法解决,谁能帮我改改?
当第一次拖动层时,层的位置会偏离很远。
呃。。。这涉及到一个style的问题。。。
在ie和firefox中,obj.style这个东西实际上只是取得元素中属性style中的值!
如下例,你会发现style块中的属性一个都取不到!
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=t.style;
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
看到了没?前两个style 为空,后两个才有值。
如果是ie,问题很好解决,只要把style改成currentStyle即可。
IE Only
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=t.currentStyle;
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
FF only
复制代码 代码如下:
<style>
#test{width:100px;background-color:red;}
</style>
<script>
window.onload=function(){
var t=document.getElementById('test')
var ts=document.defaultView.getComputedStyle(t, null);
t.innerHTML=
"t.style.width:"+ts.width+"<br />"+
"t.style.backgroundColor:"+ts.backgroundColor+"<br />"+
"t.style.color:"+ts.color+"<br />"+
"t.style.paddingLeft:"+ts.paddingLeft
}
</script>
<body>
<div id="test" style="color:yellow;padding-left:100px;">
</div>
</body>
我绕了半天,你明白你的错误原因了吗?你的style全都是文档级style,而你试图获取left的时候,第一次获得的只是0,自然会把你的框给挪到边上去了。
12下一页阅读全文
标签:
拖动层效果,兼容IE和FF!
南强小屋 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
南强小屋 Design By 杰米
暂无拖动层效果,兼容IE和FF!第1/2页的评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。