<head>
<script language="JavaScript1.2">
function Hidecontent(divid) {
divid.filters.revealTrans.apply();
divid.style.visibility = "hidden";
divid.filters.revealTrans.play();
}
</script>
</head><body>
<script language="JavaScript">
<!--
var w=screen.width
if(w=="") $w=1024
if(w>1024){
w=(w-1024)/2+150
}else if(w<1024){
w=(w-1024)/2+150
}else{
w=150
}
document.write(w);
//-->
</script><div id='READ' style='left:这里如何得到script中的值px;top:260px;width:486;position:absolute;filter:revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5);z-index:10;' class=article><table border='1' cellpadding='3' cellspacing='0' width='486' bgcolor=#F4F1D9 bordercolor='#FFFF00'><tr><td bgcolor='#FFFF00'><font style='text-decoration: none' title='关闭提醒' color='#FF0000'>浮动广告</font></td><td align='right' bgcolor='#FFFF00'><a href='javascript:void(Hidecontent(READ))'><font style='text-decoration:none;'title='关闭广告'><b>×</b></font></a></td></tr><tr><td height='100' valign='middle' align='center' colspan='2'>广告内容<br>
</body></html>
<script language="JavaScript1.2">
function Hidecontent(divid) {
divid.filters.revealTrans.apply();
divid.style.visibility = "hidden";
divid.filters.revealTrans.play();
}
</script>
</head><body>
<script language="JavaScript">
<!--
var w=screen.width
if(w=="") $w=1024
if(w>1024){
w=(w-1024)/2+150
}else if(w<1024){
w=(w-1024)/2+150
}else{
w=150
}
document.write(w);
//-->
</script><div id='READ' style='left:这里如何得到script中的值px;top:260px;width:486;position:absolute;filter:revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5);z-index:10;' class=article><table border='1' cellpadding='3' cellspacing='0' width='486' bgcolor=#F4F1D9 bordercolor='#FFFF00'><tr><td bgcolor='#FFFF00'><font style='text-decoration: none' title='关闭提醒' color='#FF0000'>浮动广告</font></td><td align='right' bgcolor='#FFFF00'><a href='javascript:void(Hidecontent(READ))'><font style='text-decoration:none;'title='关闭广告'><b>×</b></font></a></td></tr><tr><td height='100' valign='middle' align='center' colspan='2'>广告内容<br>
</body></html>
解决方案 »
- 怎么把PHP无级联动的数据输出到JS无级联动里?
- 程序运行后加载不上中文,求解了
- 关于window.onload与body.onload调用对象方法的问题......
- javascript验证表单问题求教!为什么总没能限制住
- 关于JQuery 的验证
- 问一个表单取值的问题,
- 新手问题,请帮忙
- 如何让javascript在一定时间内从固定的文本文件内提取信息?
- 这样的写法错在哪儿?var floorelement=window.opener.document.getElementsById("Room_area_<%=room_id%>")
- 怎样在网页中禁止打印?
- javascript怎么修改xml的某个属性值
- 如何用js查找盘符下 exe 文件,并自动运行呢?
var w=screen.width
if(w=="") $w=1024
if(w>1024){
w=(w-1024)/2+150
}else if(w<1024){
w=(w-1024)/2+150
}else{
w=150
}
document.write("<div id='READ' style='left:"+w+"px;top:260px;width:486;position:absolute;filter:revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5);z-index:10;' class=article><table border='1' cellpadding='3' cellspacing='0' width='486' bgcolor=#F4F1D9 bordercolor='#FFFF00'><tr><td bgcolor='#FFFF00'><font style='text-decoration: none' title='关闭提醒' color='#FF0000'>浮动广告</font></td><td align='right' bgcolor='#FFFF00'><a href='javascript:void(Hidecontent(READ))'><font style='text-decoration:none;'title='关闭广告'><b>×</b>< /font></a></td></tr><tr><td height='100' valign='middle' align='center' colspan='2'>广告内容<br>");
}
//-->
scrollHeight: 获取对象的滚动高度。 scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离scrollWidth:获取对象的滚动宽度offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度offsetLeft:获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置offsetTop:获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置 event.clientX 相对文档的水平座标event.clientY 相对文档的垂直座标event.offsetX 相对容器的水平坐标event.offsetY 相对容器的垂直坐标 document.documentElement.scrollTop 垂直方向滚动的值event.clientX+document.documentElement.scrollTop 相对文档的水平座标+垂直方向滚动的量
谢谢,你在办法的确达到了效果,但能不能<div id='READ' style='left:"+w+"px;top:260px;……不包含在script里面,不用document.write?
吧脚本放在这个DIV后面<div id='READ'.....</div>
<!--之后跟脚本-->
<script language="JavaScript">
<!--
var w=screen.width
if(w=="") $w=1024
if(w>1024){
w=(w-1024)/2+150
}else if(w<1024){
w=(w-1024)/2+150
}else{
w=150
}
//感觉直接这样计算就可以了 var w=w==''?150:(w-1024)/2+150
document.getElementById('READ').style['left']=w+'px';
//-->
</script>
脚本的执行时机必须是页面已经加载了 div{id='READ'} 这个标签
考虑页面显示效果 <div id='READ' ></div> 可以先设置隐藏 当设置了style.left后再取消隐藏