// JScript 文件 通过元素id得到对象的函数

2020-01-05 19:23 来源:未知

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<HEAD>
<TITLE>随滚动条移动的层 - <A href=";
<META HTTP-EQUIV="Content-Type" CONTENT="text/html" charset="gb2312">
</HEAD>
<style>
<!--
.div{
 position: absolute;
 border: 2px solid red;
 background-color: #EFEFEF;
 line-height:90px;
 font-size:12px;
 z-index:1000;
}
-->
</style>
<BODY>
<div id="Javascript.Div1" class="div" style="width: 240px; height:90px" align="center">正中...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc1(){
 document.getElementById("Javascript.Div1").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("Javascript.Div1").offsetHeight)/2)+"px";
 document.getElementById("Javascript.Div1").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("Javascript.Div1").offsetWidth)/2)+"px";
}
</SCRIPT>

复制代码 代码如下:

<html>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
/*弹出半透明层代码*/
function ShowNo() //隐藏两个层
{
document.getElementById("doing").style.display="none";
document.getElementById("divInfoShow").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("divInfoShow").style.display="";
}
function getRange() //得到屏幕的大小
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth;

一、在中间显示;(参考:sky100articles1790515)

<div id="Javascript.Div2" class="div" style="width: 240px; height:90px" align="center">左上...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc2(){
 document.getElementById("Javascript.Div2").style.top=(document.documentElement.scrollTop)+"px";
 document.getElementById("Javascript.Div2").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ; <html xmlns="
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ;
<html xmlns=" ;
<HEAD>
<TITLE>随滚动条移动的层 </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html" charset="gb2312">
</HEAD>
<style>
<!--
.div{
position: absolute;
border: 2px solid red;
background-color: #EFEFEF;
line-height:90px;
font-size:12px;
z-index:1000;
}
-->
</style>
<BODY>
<div id="Javascript.Div1" class="div" style="width: 240px; height:90px" align="center">正中...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc1(){
document.getElementById("Javascript.Div1").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("Javascript.Div1").offsetHeight)/2)+"px";
document.getElementById("Javascript.Div1").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("Javascript.Div1").offsetWidth)/2)+"px";
}
</SCRIPT>
<div id="Javascript.Div2" class="div" style="width: 240px; height:90px" align="center">左上...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc2(){
document.getElementById("Javascript.Div2").style.top=(document.documentElement.scrollTop)+"px";
document.getElementById("Javascript.Div2").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
/*弹出半透明层代码结束*/
//-->
</SCRIPT>
<!--加一个半透明层-->
<div id="doing" style="filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3;
background-color: #000; width: 100%; height: 100%; z-index: 1000; position: absolute;
left: 0; top: 0; display: none; overflow: hidden;">
</div>
<!--加一个信息显示层-->
<div id="divInfoShow" style="border: solid 10px #898989; background: #fff; padding: 10px;
width: 590px; z-index: 1001; position: absolute; display: none; top: 63%; left: 65%;
margin: -200px 0 0 -400px; ">
<div style="padding: 3px 15px 3px 15px; text-align: left; vertical-align: middle;">
<div align="center">
<br />
<br />
<asp:Label ID="lbl_Info" runat="server">你确定要XXX吗?<br/>点击取消关闭当前窗口。</asp:Label> </div>
<br />
<div align="center">
<input type="button" value="确 定" /> 
<input id="BttCancel" type="button" value="取 消" onclick="ShowNo()" /><br />
<br />
</div>
</div>
</div>
<input type="button" onclick="showFloat();void(0);"/>
</body>
</html>

复制代码 代码如下:

<div id="Javascript.Div3" class="div" style="width: 240px; height:90px" align="center">左下...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc3(){
 document.getElementById("Javascript.Div3").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Div3").offsetHeight)+"px";
 document.getElementById("Javascript.Div3").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

<div id="Javascript.Div3" class="div" style="width: 240px; height:90px" align="center">左下...</div>
<SCRIPT LANGUAGE="JavaScript">
function sc3(){
document.getElementById("Javascript.Div3").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("Javascript.Div3").offsetHeight)+"px";
document.getElementById("Javascript.Div3").style.left=(document.documentElement.scrollLeft)+"px";
}
</SCRIPT>

永利平台娱乐,.ordersearchDivCss
{
position: absolute;
z-index: 100;
display: block;
background-color: #6ec1df;
}
<div class="ordersearchDivCss" id="DivMain" style="width: 400px; height:200px" align="center"></div>

TAG标签:
版权声明:本文由永利平台娱乐发布于新闻动态,转载请注明出处:// JScript 文件 通过元素id得到对象的函数