我现在的问题是:
我把JS加在网站的TOP.aspx页面。
单得把这个JS放在非顶(top)页面内,可以正常弹出。现在是放在上面了,也从上面弹了,有什么好的办法吗?我用的是框架?
分上面,上为:top.aspx 下为:down.aspx<Script language="javascript">
<!--
/*========================右下角弹层=================================================*/
//window.onload = getMsg;
//window.onresize = resizediv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
divTop = parseInt(document.getElementById("eMeng").style.top,10)
divLeft = parseInt(document.getElementById("eMeng").style.left,10)
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
document.getElementById("eMeng").style.visibility="visible"
objTimer = window.setInterval("movediv()",10)
}
catch(e){}
}function resizediv()
{
i+=1
if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}function movediv()
{
try
{
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer)
objTimer = window.setInterval("resizediv()",1)
}
divTop = parseInt(document.getElementById("eMeng").style.top,10)
document.getElementById("eMeng").style.top = divTop - 2
}
catch(e){}
}function closediv()
{
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer)
}
-->
</Script>以上代码来自网上,哈!
我把JS加在网站的TOP.aspx页面。
单得把这个JS放在非顶(top)页面内,可以正常弹出。现在是放在上面了,也从上面弹了,有什么好的办法吗?我用的是框架?
分上面,上为:top.aspx 下为:down.aspx<Script language="javascript">
<!--
/*========================右下角弹层=================================================*/
//window.onload = getMsg;
//window.onresize = resizediv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
divTop = parseInt(document.getElementById("eMeng").style.top,10)
divLeft = parseInt(document.getElementById("eMeng").style.left,10)
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;// divHeight
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
document.getElementById("eMeng").style.visibility="visible"
objTimer = window.setInterval("movediv()",10)
}
catch(e){}
}function resizediv()
{
i+=1
if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}function movediv()
{
try
{
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(objTimer)
objTimer = window.setInterval("resizediv()",1)
}
divTop = parseInt(document.getElementById("eMeng").style.top,10)
document.getElementById("eMeng").style.top = divTop - 2
}
catch(e){}
}function closediv()
{
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer)
}
-->
</Script>以上代码来自网上,哈!
document.top.body
做如下修改document.body=>window.top.document.body
document.top.body
---可以试试
这个JS在TOP下面<Script language="javascript">
<!--
/*========================右下角弹层=================================================*/
//window.onload = getMsg;
//window.onresize = resizediv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
divTop = parseInt(document.getElementById("eMeng").style.top,10)
divLeft = parseInt(document.getElementById("eMeng").style.left,10)
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
docWidth = window.top.document.body.clientWidth;
docHeight = window.top.document.body.clientHeight;
document.getElementById("eMeng").style.top = parseInt(window.top.document.body.scrollTop,10) + docHeight + 10;// divHeight
document.getElementById("eMeng").style.left = parseInt(window.top.document.body.scrollLeft,10) + docWidth - divWidth
document.getElementById("eMeng").style.visibility="visible"
objTimer = window.setInterval("movediv()",10)
}
catch(e){}
}function resizediv()
{
i+=1
if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}function movediv()
{
try
{
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(window.top.document.body.scrollTop,10)))
{
window.clearInterval(objTimer)
objTimer = window.setInterval("resizediv()",1)
}
divTop = parseInt(document.getElementById("eMeng").style.top,10)
document.getElementById("eMeng").style.top = divTop - 1
}
catch(e){}
}function closediv()
{
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer)
}
-->
</Script>s框架是这样的:
<frameset border="0" framespacing="0" rows="80,*,0" frameborder="0">
<frame id="topMenu" name="topMenu" src="top.aspx" frameborder="0" noresize scrolling="no"></frame>
<frameset id="valueFrame" name="valueFrame" framespacing="0" frameborder="0" cols="194">
<frame id="showInfo" name="showInfo" src="down.aspx">
</frameset>
<noframes>
</noframes>
</frameset>
楼主是想在框架的主显示区显示这个弹出层,但因为主显示区的页面是一直在变的,没有办法,只好放到了TOP页面。但放到了TOP页面,层也只从TOP中弹出了。是不是这样?
这句的意思是 html 代码遵循 w3c 标准js 代码中 设置 top 和 left 的时候 最后要加上 px eg:document.getElementById("eMeng").style.top = parseInt(window.top.document.body.scrollTop,10) + docHeight + 10;// divHeight=>document.getElementById("eMeng").style.top = parseInt(window.top.document.body.scrollTop,10) + docHeight + 10+'px';// divHeight
<!--
/*========================右下角弹层=================================================*/
//window.onload = getMsg;
//window.onresize = resizediv;
//window.onerror = function(){}
//短信提示使用(asilas添加)
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
try{
divTop = parseInt(document.getElementById("eMeng").style.top,10);
divLeft = parseInt(document.getElementById("eMeng").style.left,10);
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = window.top.document.body.clientWidth;
docHeight = window.top.document.body.clientHeight;document.getElementById("eMeng").style.top = parseInt(window.top.document.body.scrollTop,10) + docHeight + 10+'px';// divHeight
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth+'px';
document.getElementById("eMeng").style.visibility="visible"
objTimer = window.setInterval("movediv()",10)
}
catch(e){}
}function resizediv()
{
i+=1
if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}function movediv()
{
try
{
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(window.top.document.body.scrollTop,10)))
{
window.clearInterval(objTimer)
objTimer = window.setInterval("resizediv()",1)
}
divTop = parseInt(document.getElementById("eMeng").style.top,10)
document.getElementById("eMeng").style.top = divTop - 1+'px';
}
catch(e){}
}function closediv()
{
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer)
}
-->
我是把DTD那一行去了,才好用,在最下面弹的
就是docHeight = window.top.document.body.clientHeight;
=>
docHeight = window.top.document.documentElement.clientHeight;就可以了
解决方法有两种,一种是不使用frame,换成iframe对页面进行布局
还有一种,解决方法如下:
跨 Frame下拉菜单
http://www.cnblogs.com/GavinCome/archive/2008/01/16/1041806.html
<iframe id="iFrame1" name="iFrame1" width="100%" height="80"frameborder="0" src="top.aspx" onload="{TuneHeight('iFrame1','iFrame1');}"></iframe>
<iframe id="iFrame2" name="iFrame2" width="100%" frameborder="0" src="ycwbcs.aspx" onload="{TuneHeight('iFrame2','iFrame2');}"></iframe>这样也不行,解决不了!
{
i+=1
//if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}
,就改了这一个是吧?
{
i+=1
//if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
}=》function resizediv()
{
i+=1
if(i>300)
{
closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
i=0;
}
}
你作一个小页面或者直接用TOP,不停刷新,当window.onload的时候,执行JS弹出层不就行了。