如何在网页右下角出现一个像QQ系统消息一样的浮动窗口(jsp)_百度知 ...
发布网友
发布时间:2022-04-29 16:04
我来回答
共4个回答
热心网友
时间:2022-04-23 14:18
用不着java技术,用js完全可以实现,下面是个例子,你可以根据自己的需要改一下,千万别告诉我你不会用下面的代码啊
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link rel="stylesheet" href="images/style.css" type="text/css" />
<style type="text/css">
<!--
.divyidong{
border: 2px solid #cc6633;
}
-->
</style>
<script src="images/noticediv.js" language="javascript" type="text/javascript"></script>
</head>
<body class="body">
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" Width="500px">
<div id="boysoft" class="divyidong" style="right: 0; position: absolute; visibility: hidden; z-index: 1">
<table border="0" cellpadding="0" cellspacing="0" width="500px">
<tr>
<td onmousedown="initializedragie()" style="cursor: move; height: 20px; background-color: #cc6633;
font-weight: bold; color: #ffffff; font-size: 14px; width: 476px;" align="left">
系统消息
</td>
<td style="cursor: move; height: 20px; background-color: #cc6633; width: 24px;" align="right">
<img src="images/119.jpg" style="cursor: auto;" title="关闭" onclick="toggle('boysoft')" /></td>
</tr>
<tr>
<td colspan="2">
<table cellpadding="0" cellspacing="0" style="background-color: #fcf9f2" width="500px">
<tbody>
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="99%">
<tbody>
<tr>
<td align="left">
<br />
春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐春节快乐</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
</asp:Panel>
</form>
</body>
</html>
<script type="text/javascript">
//加载窗体后从右下角弹出窗体
setTimeout("getMsg()",1000);
window.onerror = function(){}
//window.onerror当发生错误时发生的事
var sdivTop,sdivLeft,sdivWidth,sdivHeight,sdocHeight,sdocWidth,sobjTimer,i = 0;
function getMsg()
{
try{
sdivTop = parseInt(document.getElementById("boysoft").style.top,10)
sdivLeft = parseInt(document.getElementById("boysoft").style.left,10)
sdivHeight = parseInt(document.getElementById("boysoft").offsetHeight,10)
sdivWidth = parseInt(document.getElementById("boysoft").offsetWidth,10)
sdocWidth = document.documentElement.clientWidth;
sdocHeight =document.documentElement.scrollTop+document.documentElement.clientHeight;
document.getElementById("boysoft").style.top = parseInt(document.body.scrollTop,10) + sdocHeight + 10;// divHeight
document.getElementById("boysoft").style.left = parseInt(document.body.scrollLeft,10) + sdocWidth - sdivWidth
document.getElementById("boysoft").style.visibility="visible"
sobjTimer = window.setInterval("moveDiv()",10)
//解释:document.write (Balises); Time=window.setInterval("Alors()",10);输出文字,每10毫秒,变化一次。
}
catch(e){}
}
function moveDiv()
{
try
{
if(parseInt(document.getElementById("boysoft").style.top,10) <= (sdocHeight - sdivHeight + parseInt(document.body.scrollTop,10)))
{
window.clearInterval(sobjTimer)
//解释:clearInterval() 方法可取消由 setInterval() 设置的 timeout。clearInterval() 方法的参数必须是由 setInterval() 返回的 ID 值。
}
else
{
sdivTop = parseInt(document.getElementById("boysoft").style.top,10)
document.getElementById("boysoft").style.top = sdivTop - 4
}
}
catch(e){}
}
//关闭层
function toggle(targetid){
if (document.getElementById){
target=document.getElementById(targetid);
target.style.display="none";
}
}
//移动层
var dragswitch=0
var nsx
function drag_dropns(name){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}
function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}
function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}
//drag drop function for IE 4+////
/////////////////////////////////
var dragapproved=false
function drag_dropie(){
if (dragapproved==true){
document.all.boysoft.style.pixelLeft=tempx+event.clientX-iex
document.all.boysoft.style.pixelTop=tempy+event.clientY-iey
return false
}
}
function initializedragie(){
iex=event.clientX
iey=event.clientY
tempx=boysoft.style.pixelLeft
tempy=boysoft.style.pixelTop
dragapproved=true
document.onmousemove=drag_dropie
}
if (document.all){
document.onmouseup=new Function("dragapproved=false")
}
////drag drop functions end here//////
function hidebox(){
if (document.all)
boysoft.style.visibility="hidden"
else if (document.layers)
document.boysoft.visibility="hide"
}
//让层跟着滚动条滚动
function sc5(){
document.getElementById("boysoft").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("boysoft").offsetHeight)+"px";
document.getElementById("boysoft").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("boysoft").offsetWidth)+"px";
}
window.onscroll=sc5;
window.onresize=sc5;
// window.onload=sc5;
</script>
热心网友
时间:2022-04-23 15:36
右下角弹出窗口那个是用到了popup技术,我这有一个最简单的,网上很多例子你可以自己找找更好的
-----------------------------------------
<SCRIPT>
var oPopup = window.createPopup();
var popTop=50;
function popmsg(msgstr){
var winstr="";
winstr+="";
winstr+="<h2 style=\"color:#000;font-size:12px;line-height:20px;width:auto;height:229px;margin:0;padding:40px 10px 10px 10px;background:#f5f5f5;border:1px #000 solid;\">"+msgstr+"</h2>";
oPopup.document.body.innerHTML = winstr;
popshow();
}
function popshow(){
window.status=popTop;
if(popTop>1720){
clearTimeout(mytime);
oPopup.hide();
return;
}else if(popTop>1520&&popTop<1720){
oPopup.show(screen.width-250,screen.height,241,1720-popTop);
}else if(popTop>1500&&popTop<1520){
oPopup.show(screen.width-250,screen.height+(popTop-1720),241,172);
}else if(popTop<180){
oPopup.show(screen.width-250,screen.height,241,popTop);
}else if(popTop<220){
oPopup.show(screen.width-250,screen.height-popTop,241,172);
}
popTop+=10;
var mytime=setTimeout("popshow();",50);
}
popmsg("山西省*12:20分抵达首都机场,请及时迎接");</SCRIPT>
---------------------------------------------
至于到一个时间就自动提醒,你可以使用js的
window.setInterval("run();", 1000); //每隔多少毫秒运行run方法一次
热心网友
时间:2022-04-23 17:10
直接到网上下JS www.lanrentuku.com 里面有
懒人图酷
热心网友
时间:2022-04-23 19:02
楼上的大哥还真行啊,用.NET里面的忽悠人...