|
楼主 |
发表于 2014-7-19 10:21:27
|
显示全部楼层
下面是js代码:
var hover='orange',normal='slategray',normalbordercolor='#336699',strTop='',strLeft='';
window.onload =window.onscroll = scrollMsgTip;
var moveable=false;
var x0=0,y0=0,x1=0,y1=0;
//开始拖动;
function startDrag(obj)
{
if(event.button==1)
{
$("divDrag").style.visibility = "visible";
//锁定标题栏;
obj.setCapture();
//定义对象;
var win = $("msgtip");
//记录鼠标和层位置;
x0 = event.clientX;
y0 = event.clientY;
x1 = parseInt(win.style.left);
y1 = parseInt(win.style.top);
//记录颜色;
//normal = obj.style.backgroundColor;
//改变风格;
obj.style.backgroundColor = hover;
win.style.borderColor = hover;
// win.style.left = x1 ;
// win.style.top = y1 ;
moveable = true;
event.srcElement.setCapture();
}
}
//拖动;
function drag(obj)
{
if(moveable)
{
//小窗口宽度 高度
var winwidth=600,winheight=141;
var msg = $("msg");
var flg = msg.style.display=="none";
if(flg)
{
winwidth=300,winheight=25;
}
obj.setCapture();
var win = $("msgtip");
var bg = $("bg");
var x=x1 + event.clientX - x0;
var y=y1 + event.clientY - y0;
var l=document.body.scrollWidth;
var h=document.body.scrollHeight;
if(x<0){x=0;}
if(x+winwidth>l){x=l-winwidth;} //小窗口宽度为600
if(y<0){y=0;}
if(y+winheight>h){y=h-winheight;}
win.style.left =x;// x1 + event.clientX - x0;
win.style.top =y;// y1 + event.clientY - y0;
}
}
//停止拖动;
function stopDrag(obj)
{
if(moveable)
{
$("divDrag").style.visibility = "hidden";
var win = $("msgtip");
var msg = $("msg");
win.style.borderColor = normalbordercolor;
obj.style.backgroundColor = normal;
msg.style.color = normal;
obj.releaseCapture();
moveable = false;
event.srcElement.releaseCapture();
}
}
function min(obj)
{
var win = $("msgtip");
var tit = $("msgTitle");
var msg = $("msg");
var flg = msg.style.display=="none";
if(flg)
{
win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height);
win.style.width = "600px";
msg.style.display = "block";
obj.innerHTML = "<img src=\"zuixiao.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"0";
$("btn").title = "最小化";
if(strLeft!="" && strTop!="")
{
win.style.left = strLeft;
win.style.top = strTop;
}
else
{
scrollTip();
}
}
else
{
closeDiv();
}
}
function closeDiv()
{
var strisview=$("isView").value;
if(strisview=="1")
{
timeFrame.window.document.getElementById("glowtext").innerHTML="请更新学习时间!";
//timeFrame.window.startglowing();
return;
}
var win = $("msgtip");
var tit = $("msgTitle");
var msg = $("msg");
win.style.height = parseInt(tit.style.height);
win.style.width = "300px";
$("btn").innerHTML = "<img src=\"zuida.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"2";
$("btn").title = "最大化";
msg.style.display = "none";
$("bg").style.visibility = "hidden";
strLeft=win.style.left;
strTop=win.style.top;
scroll();
}
var tScaler; //计时器
//随机展开DIV
function Time()
{
var win = $("msgtip");
var tit = $("msgTitle");
var msg = $("msg");
//var num = Math.round(Math.random()*10) + 10;//Math.floor(Math.random()*0) + 1 //产生一个 10-20之间的随机数
//tScaler = setTimeout("Time()",num * 60 * 1000);//根据随机数分钟数显示 IFrame ,在 IFrame 中提交时间
if(!msg) return;
win.style.height = parseInt(msg.style.height) + parseInt(tit.style.height);
win.style.width = "600px";
msg.style.display = "block";
$("btn").innerHTML = "<img src=\"zuixiao.jpg\" style=\"vertical-align: bottom; border:0px;\"/>";//"0";
$("bg").style.visibility = "visible";
scrollCenter();
$("isView").value="1";
//学习计时停止
timeFrame.window.stopTimer();
stopScaler();
//窗口置前
self.focus();
window.onblur=function (){self.focus();}
}
function stopScaler(){
//alert('stopScaler');
clearTimeout(tScaler);
}
function statScaler(){
var num = Math.round(Math.random()*9) + 11;//Math.floor(Math.random()*0) + 1;//产生一个 10-20之间的随机数
//alert(num);
tScaler = setTimeout("Time()",num * 60 * 1000);//根据随机数分钟数显示 IFrame ,在 IFrame 中提交时间//
$("isView").value="0";
window.onblur=function (){}
}
g_blnCheckUnload = true;
window.onbeforeunload = function() {
if(g_blnCheckUnload)
{
return '点"确定"结束学习,本次学习时间不会累计。点"取消"可继续学习。';
}
}
function cg()
{
timeFrame.window.stopTimer();
min($("btn"));
alert('更新学习时间成功!');
timeFrame.window.DoConverseCallTimer();
stopScaler();
statScaler();
}
function isView0()
{
$("isView").value="0";
}
function setPrompt(itype)
{
if(itype=="0")
{
timeFrame.window.document.getElementById("glowtext").innerHTML="更新学习时间中请等待...";
}
else
{
timeFrame.window.document.getElementById("glowtext").innerHTML="";
}
} |
|