我现在的问题是:
我把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>以上代码来自网上,哈!

解决方案 »

  1.   

    top 不是放在框架页中的么?
      

  2.   

    就是了。问题的原因是 当前窗口不是顶端窗口做如下修改document.body=>window.top.document.body
    document.top.body
      

  3.   


    做如下修改document.body=>window.top.document.body
      

  4.   

    window.top.document.body
    document.top.body
    ---可以试试
      

  5.   


    这个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>
      

  6.   

    放在框架里直接不弹了,单独运行TOP弹,但是也不是在最下面弹的
      

  7.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">为什么去掉这个就能从下面弹出来了呢?
      

  8.   

    呵呵,搞定了?
    楼主是想在框架的主显示区显示这个弹出层,但因为主显示区的页面是一直在变的,没有办法,只好放到了TOP页面。但放到了TOP页面,层也只从TOP中弹出了。是不是这样?
      

  9.   


    这句的意思是 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
      

  10.   

    不好用,还是那样,单独打开TOP也不管事了,除非把那行DTD加上
      

  11.   

    你把DTD 加上 之后出现什么问题
      

  12.   

    我TOP那个页面就是上半一小半。然后我点击不是从最下面出,是在中间出来了,DTD加上了
      

  13.   


    <!--
    /*========================右下角弹层=================================================*/  
    //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)
    }
    -->
      

  14.   


    我是把DTD那一行去了,才好用,在最下面弹的
      

  15.   

    原因是 w3c 标准下 document.body.clientHeight 的取值 与 非 w3c 标准 不一致改成 document.documentElement.clientHeight
    就是docHeight = window.top.document.body.clientHeight;
    =>
    docHeight = window.top.document.documentElement.clientHeight;就可以了
      

  16.   

    DIV是不支持跨frame的,所以你在Top上的层,在Main中是弹不出来的。
    解决方法有两种,一种是不使用frame,换成iframe对页面进行布局
    还有一种,解决方法如下:
    跨 Frame下拉菜单
    http://www.cnblogs.com/GavinCome/archive/2008/01/16/1041806.html
      

  17.   

    我就是按照34#改的,可以了,但是放到frame 里就是不弹出了,郁闷
      

  18.   

    应该是 DIV是不能跨frame 的原因. 换成 iframe 应该可以解决问题如果你只想使用frameset 的话, 我回来再帮你想办法, 出门了.
      

  19.   


    <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>这样也不行,解决不了!
      

  20.   

    现在 可以这样,如果 你的框架页固定只有 top 和 down 的话,你可以在 down 中也放一个同样的div然后 让down 中的div 显示即可
      

  21.   

    用样式绝对定位到右下角,再加上z-index属性让其始终显示在最上层!
      

  22.   

    function resizediv()
    {
    i+=1
    //if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
     
    }
    ,就改了这一个是吧?
      

  23.   

    function resizediv()
    {
    i+=1
    //if(i>300) closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
     
    }=》function resizediv()
    {
    i+=1
    if(i>300)

       closediv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
       i=0;
    }
     
    }
      

  24.   

    楼主是指定时扫描数据库,有短信到了,就自动弹出右下角的窗口。
    你作一个小页面或者直接用TOP,不停刷新,当window.onload的时候,执行JS弹出层不就行了。
      

  25.   

    document.getElementById("eMeng").style.top = divTop - 1+'px';=》document.getElementById("eMeng").style.top = divTop - 10+'px';