公告窗口如果用弹出式窗口的话,有可能会被些什么上网助手给屏蔽了!所以写了个公告DIV的JS。
演示地址:http://blog.csdn.net/bgu/
代码如下:(放入到Body区域即可)
<
div id
=
"
affiche
"
ondblclick
=
"
closeDiv();
"
style
=
"
BORDER-RIGHT: black 1px outset; BORDER-TOP: black 1px outset; BORDER-LEFT: black 1px outset; WIDTH: 30%; CLIP: rect(auto auto auto auto); BORDER-BOTTOM: black 1px outset; POSITION: absolute; HEIGHT: 30%; BACKGROUND-COLOR: whitesmoke; TEXT-ALIGN: center;
"
align
=
"
center
"
>
< table height = " 100% " width = " 100% " >
< tr >
< td vAlign = " middle " align = " center " height = " 100% " >
此处为公告内容
< div id = " timeout " ></ div >
</ td >
</ tr >
</ table >
</ div >
< script language = " javascript " >
var intOut = 10 ;
TimeDiv();
function closeDiv()
{
document.getElementById( " affiche " ).style.display = " none " ;
}
function TimeDiv()
{
-- intOut;
if ( intOut > 1 )
{
window.setTimeout( " TimeDiv() " , 1000 );
document.getElementById( " timeout " ).innerText = intOut + " 秒后/双击窗口自动关闭! " ;
}
else
{
closeDiv();
}
}
var objDiv = document.getElementById( " affiche " );
SetDiv();
function SetDiv()
{
objDiv.style.top = (document.body.offsetHeight - objDiv.offsetHeight) / 2 + document.body.scrollTop;
objDiv.style.left = (document.body.offsetWidth - objDiv.offsetWidth) / 2 ;
if ( intOut>1 )
{
window.setTimeout( " SetDiv() " ,2 00 );
}
}
</ script >
< table height = " 100% " width = " 100% " >
< tr >
< td vAlign = " middle " align = " center " height = " 100% " >
此处为公告内容
< div id = " timeout " ></ div >
</ td >
</ tr >
</ table >
</ div >
< script language = " javascript " >
var intOut = 10 ;
TimeDiv();
function closeDiv()
{
document.getElementById( " affiche " ).style.display = " none " ;
}
function TimeDiv()
{
-- intOut;
if ( intOut > 1 )
{
window.setTimeout( " TimeDiv() " , 1000 );
document.getElementById( " timeout " ).innerText = intOut + " 秒后/双击窗口自动关闭! " ;
}
else
{
closeDiv();
}
}
var objDiv = document.getElementById( " affiche " );
SetDiv();
function SetDiv()
{
objDiv.style.top = (document.body.offsetHeight - objDiv.offsetHeight) / 2 + document.body.scrollTop;
objDiv.style.left = (document.body.offsetWidth - objDiv.offsetWidth) / 2 ;
if ( intOut>1 )
{
window.setTimeout( " SetDiv() " ,2 00 );
}
}
</ script >