类似新浪网的 弹出视频功能实现代码

javascript代码,一般放到 head中

复制代码 代码如下:


<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>1300) closeDiv() //客户想不用自动消失由用户来自己关闭所以屏蔽这句
try{
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 = docHeight - divHeight + parseInt(document.body.scrollTop,10)
document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
}
catch(e){}
}
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 - 1
}
catch(e){}
}
function closeDiv()
{
document.getElementById('eMeng').innerHTML='';
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer)
}
-->
</Script>



下面的代码放到body中

复制代码 代码如下:


<!--温馨提示代码开始-->
<DIV id=eMeng>
<TABLE border=0 cellPadding=0 cellSpacing=0 bgColor=#AFDCF3>
<TR bgColor=#6699cc>
<TD height=24>教育的意义</TD>
<TD vAlign=center align=right><span title=关闭 onclick=closeDiv() >×</span><!--<IMG title=关闭 onclick=closeDiv() hspace=3 src="https://www.jb51.net/msgClose.jpg" src="https://www.jb51.net/msgClose.jpg">--></TD>
</TR>
<TR>
<TD height=225 colSpan=2 valign="bottom"><span>
<object classid="clsid:05589FA1-C356-11CE-BF01-00AA0055595A">
<param value="/0" />
<param value="-1" />
<!--控制播放方式: x=1,打开网页自动播放; x=0,按播放键播放。-->
<param value="-1" />
<param value="0" />
<param value="-1" />
<param value="-1" />
<param value="0" />
<param value="0" />
<param value="0" />
<param value="16777215" />
<param value="0" />
<param value="-1" />
<param value="-1" />
<param value="-1" />
<param value="0" />
<param value="-1" />
<param value="资源链接地址.mpg" valuetype="ref" />
<!--文件路径-->
<param value="0" />
<param value="0" />
<param value="0" />
<!--控制重复次数: “x”为几重复播放几次; x=0,无限循环。-->
<param value="1" />
<param value="-1" />
<param value="-1" />
<param value="-1" />
<param value="0" />
<param value="0" />
<param value="-1" />
<param value="-480" />
</object>
</span></TD>
</TR>
</TABLE>


具体的实现代码测试:


[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjwzdd.html