<html>
<head>
<style type="text/css">
<!--
p { color: blue; font-size: 37px; font-family: impact }
-->
</style>
<title>auto set Tip's box</title>
</head>
<script language="javascript">
var titlePopup=window.createPopup();
var content;
var tID;
var time=1000;
var yOffset;
var xOffset;
var width;
var height;
/*
* This fuction InitMsBox(content) is used to initialize the message-box, whose variable need your input as "message" ,
* When you need dividing the different message, you can input '<br/>' to break the line.
* If you want to change the message-box's color, border or orthers, you can rewrite the inner variable of "table" writed in this function.
*/
function InitMsgBox(content)
{
width=parseInt(document.body.clientWidth/6+28);
if(document.body.clientHeight/6>width){ width=document.body.clientHeight/6+28;}
var line=0;
if(content.length*5>width)
{
for(i=0;i<content.length;i++)
{
if((i*5)%width<5)
{
line++;
}
}
}
else
{
width=content.length*5+28;
}
var titlePopupBody = titlePopup.document.body;
titlePopupBody.style.border ="solid black 1px";
var titleContent = "";
titleContent = titleContent + "<table id='tb1' cellPadding='3' bgcolor='#65c1ff' width='100%' height='100%' border=0 cellspacing=0 cellpadding=0 style='table-layout:fixed;WORD-BREAK:break-all; WORD-WRAP: break-word'>";
titleContent = titleContent + "<tr><td style='WORD-WRAP: break-word;'><span style='font-size:12px;'>"+content+"</span></td></tr>";
titleContent = titleContent + "</table>";
titlePopupBody.innerHTML = titleContent;
xOffset=window.event.x;
yOffset=window.event.y;
var nbr=KMP(content);
height=(nbr+line)*16+8;
ShowMsgBox(xOffset,yOffset,time);
}
/*
* This function ShowMsgBox(xOffset,yOffset,time) is used to show the message-box on screen, whose
* variable xOffset and yOffset are used to set the position on screen, and the variabel time is used to set the time of reflection.
*/
function ShowMsgBox(xOffset,yOffset,time)
{
tID = window.setTimeout("MsgBox(xOffset, yOffset)",time);
}
function MsgBox(xOffset, yOffset)
{
if (window.closed)
{
window.clearInterval(tID);
}
else
{
if(xOffset<document.body.clientWidth-width)
{
if(yOffset<document.body.clientHeight-height)
{
titlePopup.show(xOffset, yOffset+20, width, height, top.document.body);
}
else
{
titlePopup.show(xOffset, yOffset-height-20, width, height, top.document.body);
}
}
else
{ if(yOffset<document.body.clientHeight-height)
{
titlePopup.show(xOffset-width, yOffset+20, width, height, top.document.body);
}
else
{
titlePopup.show(xOffset-width, yOffset-height-20, width, height, top.document.body);
}
}
}
}
/*
*This fuction was writen by D.E.Knuth,J.H.Morris和V.R.Pratt,
*I just rewrited some of the codes.
*/
function KMP(tip)
{
var br="<br/>";
var i=0; var j=0; var c=0;
while(i<tip.length && j<br.length)
{
if(tip.substr(i,1)==br.substr(j,1))
{
++i;
++j;
if(j==br.length)
{
c++;
j=0;
}
}
else{i=i-j+1;j=0}
}
return c+1;
}
/*
* This fuctin load is used to initialaze the application.
*/
function load()
{
var ele =document.getElementsByName("tip");
var tipsArray=new Array();
var contentItem;
for(var i=0;i<ele.length;i++)
{
contentItem=KMP(ele[i].titletips);
ele[i].onmouseover =function() {InitMsgBox([this.titletips])};
ele[i].onmouseover =function() {InitMsgBox(this.titletips)};
ele[i].onmouseout=function() {titlePopup.hide();}
}
}
</script>
<body onload="load()">
<p><input id="Button1" style="left: 122px; position: absolute; top: 172px" type="button"
value="button" name="tip" titletips="Good morning";/></p>
<p><a id="link" name="tip" titletips="I <b>Loooooooooooooooooooooooooooooooooooooooooooooooooooooooove</b> you,<b>China</b>" >Lost</a></p>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
网页上的提示框(原代码)
共1个文件
htm:1个
4星 · 超过85%的资源 需积分: 16 65 下载量 59 浏览量
2007-12-18
11:18:49
上传
评论
收藏 2KB RAR 举报
温馨提示
这个是用JavaSript编写的网页程序.方便大家在网页上插入提示.<br>使用非常简单,只要把<scipt>代码复制到你的网页中,然后在你想出现提示的地方输入titletips="提示的内容".
资源推荐
资源详情
资源评论
收起资源包目录
网页上的提示框.rar (1个子文件)
网页上的提示框
AutoSetTipBox.htm 5KB
共 1 条
- 1
资源评论
- x1r2p32014-10-10有用处,不错的资源
- Alanqiuz2013-01-09有点坑,分数太高了
- kason_j2013-07-22很不错,用上了
- housefu2012-12-07下了,对我有用,谢谢啊
jamesbond0072
- 粉丝: 10
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功