相关代码如下,也尝试过把position调为absolute(不知道是不是这个原因),getElementById().style.left也尝试过,用alert无法读出数据,offLeft也读取不出来
代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<style>
.popup_background{background-color: #B3B3B3;position: absolute;top: 0px;right: 0px;left: 0px;bottom: 0px;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);/* 只支持IE6、7、8、9 */}
.popup{background-color: aliceblue;width: 300px;height: 230px;position: fixed;top: 0;right: 0;left: 0;bottom: 0;margin: auto;text-align: center;width:300px;border-radius:5px 5px 5px 5px;}
.popup_text{position: relative;top: 35px;font-size: 20px; font-weight: 700;color: rgba(53,53,53,1.00);}
.popup_buttom{position: relative;top: 60px;display: block;margin: 0 auto;width: 150px;height: 40px;color: white;background-color: rgba(227,107,109,1.00);border: 0px;border-radius: 5px;}
.popTitle{background: #9DACBF;height: 40px;line-height: 40px;padding: 1px;border-radius:5px 5px 0px 0px;}
.title_left{font-weight: bold;padding-left: 5px;float: left;}
.title_right{font-weight: bold;padding-right: 5px;float: right;}
</style>
<script type="text/javascript">
function openPopup(){
document.getElementById("popup_background").style.display = "block";
document.getElementById("popup").style.display = "block";
}
alert(document.querySelector("popTitle").style.left);
popTitle.onmousedown = function(e){
x = e.clientX;
y = e.clientY;
alert("aha");
l = popTitle.offsetLeft;
t = popTitle.offsetTop;
isDown = true;
popTitle.style.cursor = 'move';
alert("hah");
}
</script>
<body>
<div class="popup_background" id="popup_background"></div>
<div class="popup" id="popup">
<div class="popTitle" id="popTitle">
<span class="title_left">提示</span> <span class="title_right">×</span>
</div>
<p class="popup_text" id="popup_text">你好</p>
<input type="submit" class="popup_buttom" onclick="closePopup()" value="确 定"/>
</div>
</body>
</html>
ps:有人可以指点下移动提示框怎么做吗?