赋什么值能将div总是显示在屏幕的中央
bigo 2002-08-06 01:48:35
赋什么值能将div总是显示在屏幕的中央
屏幕中共有两个按钮,我 想在单击较上的一个时在该位置的屏幕中央显示,
当滚动到较下的一个按钮时本代码还是在上一次显示的位置,而不是该此位置的屏幕中央显示,
需要滚动条才看得见div层
用我试一下好吗?
顺便问一下大家,大家用什么编辑器定javascript,怎样记得这么多的对象属性,
用VS.Net没有 梅花雨 写的这些属性提示?
-----------------------------------------------
<html>
<head>
<script language="javascript">
function switchSpan(spanId){0D
if(document.all[spanId].style.visibility=="visible")
document.all[spanId].style.visibility="hidden";
else{
document.all[spanId].style.visibility="visible";
document.all[spanId].style.left=screen.availWidth/2-315;
/*怎样设置在屏幕的中央,不要用50这种*/
document.all[spanId].style.top=screen.availHeight/2-76;
}
}
</script>
<script language="JavaScript">
var dragapproved=false
var z,x,y
function move(){
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}}
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
</script>
<style> <!--.drag{
position:relative;
cursor:hand;
background-color: #3399CC;
0Avisibility: hidden;
width: 315px;
height: 76px;
border: 1pt solid #000000;
0A}
--></style>
</head>
<body bgcolor="#ffffff" text="#000000">
<div title="移动窗口" id="post" class="drag" name="post">发贴<a href='javascript:switchSpan("post")'>关闭<img alt="关闭发贴窗口"></a>
<table style="cursor:default" width="100" height="100" border="0" cellpadding="0" cellspacing="0" bgcolor="#eeeeee">
<tr>
<td>
<input type="text">
<br>
<input type="text">
<br>
<input type="button" value="button"></td>
</tr>
</table>
</div>
<input type="button" value="发贴" onclick='switchSpan("post")'> f f f f fff f ff
f f f ff ff<p></p>
f<p></p>
f f ff ff<p></p>
f ff<p></p>
f<p></p>
f<p></p>
f<p></p>
f<p></p>
f f<p></p>
ff<p></p>
f<p></p>
f<p></p>
f<p></p>
f<p></p>
f f ff ff<p></p>
f<p></p>
f<p></p>
f<p></p>
f<p></p>
f ff<p></p>
f f ff ff<p></p>
<input type="button" value="发贴" onclick='switchSpan("post")' ID="Button1" NAME="Button1">
f ff<p></p>
f
</body>
</html>
多谢!