俺花了不少精力才把智能提示做到这样,不知道里面有没有缺陷,希望大家来帮我寻找Bug。
数据文件(将以下红色文本复制到记事本里,重命名文件为“auto_prompt.xml”,并保存到桌面的“xmlfile”文件夹):
<?xml version="1.0" encoding="utf-8" ?>
<root>
<message>
<title>Working with the Active Cell</title>
<count>563</count>
</message>
<message>
<title>Customizing the Colors of a Cell</title>
<count>654</count>
</message>
<message>
<title>Aligning Cell Contents</title>
<count>254</count>
</message>
<message>
<title>Customizing Cell Borders</title>
<count>876</count>
</message>
<message>
<title>Customizing the Margins and Spacing of the Cell</title>
<count>567</count>
</message>
<message>
<title>Creating and Applying a Custom Style for Cells</title>
<count>875</count>
</message>
<message>
<title>Assigning a Cascading Style Sheet to a Cell</title>
<count>1324</count>
</message>
<message>
<title>Creating a Range of Cells</title>
<count>674</count>
</message>
<message>
<title>I am Michael Jordan</title>
<count>2343</count>
</message>
<message>
<title>Welcome to China</title>
<count>435</count>
</message>
<message>
<title>One World, One Dream</title>
<count>542</count>
</message>
<message>
<title>Distance makes the hearts grow fonder</title>
<count>121</count>
</message>
<message>
<title>Don't cry because it is over, smile because it happened</title>
<count>232</count>
</message>
<message>
<title>I never consider ease and joyfulness as the purpose of life itself</title>
<count>12</count>
</message>
<message>
<title>Better to light one candle than to curse the darkness</title>
<count>547</count>
</message>
<message>
<title>Love makes man grow up or sink down</title>
<count>422</count>
</message>
<message>
<title>神即道 道法自然 如来</title>
<count>123</count>
</message>
<message>
<title>
大江东去,浪淘尽,千古风流人物。故垒西边,人道是,三国周郎赤壁。乱石穿空,惊涛拍岸,卷起千堆雪。江山如画,一时多少豪杰。
遥想公瑾当年,小乔初嫁了,雄姿英发。羽扇纶巾,谈笑间,樯橹灰飞烟灭。故国神游,多情应笑我,早生华发。人生如梦,一樽还酹江月。
</title>
<count>676</count>
</message>
<message>
<title>不会下厨的裁缝一定不是一个好司机</title>
<count>121</count>
</message>
<message>
<title>物竞天择,适者生存</title>
<count>15</count>
</message>
<message>
<title>对酒当歌,人生几何</title>
<count>12</count>
</message>
<message>
<title>不患寡而患不均,不患贫而患不安</title>
<count>433</count>
</message>
<message>
<title>你的诞生带给我希望,而我希望带给你幸福</title>
<count>32</count>
</message>
<message>
<title>当生则生 当死则死</title>
<count>54</count>
</message>
<message>
<title>一夫当关 万夫莫开</title>
<count>434</count>
</message>
</root>
js脚本文件(将以下红色文本复制到记事本里,重命名文件为“auto_prompt.js”,并保存到桌面的“jsfile”文件夹):
/****************************
Author: zhouych
CreateTime: 2010/05/20 23:00:00
E-Mail: zhouych329@163.com
MSN:zhouych329@hotmail.com
QQ:120839964
CSDN:zhouych329
****************************/
/****************** Begin $ ******************/
//页面元素对象,根据ID获取
var $ = function(id){
return (id.constructor == String) ? document.getElementById(id) : id;
}
/****************** Begin $ ******************/
/****************** Begin Message ******************/
//Message保存显示的title和count
//分别与auto_prompt.xml中节点title和count对应
Message = {
title:"",
count:""
}
/****************** End Message ******************/
/****************** Begin GlobalVar ******************/
//全局变量保存一些标签ID、元素属性、中间数据、文件路径等
GlobalVar = {
Empty:"",
Data:null,
Xml_Doc:null,
Xml_Path:"xmlfile/auto_prompt.xml",
Div_Position:null,
Temp_Div:null,
Temp_Text:null,
Is_Flag_Temp_Text:true,
Text_Id:"titletext",
Button_Id:"btnSearch",
Root_Id:"rootdiv",
Div_Id:"promptdiv",
Title_Div_Id_Prefix:"div_",
Title_Div_Title_Id_Prefix:"div_title_",
Title_Div_Title:{
PaddingTop:"2px",
PaddingBottom:"2px"
},
Title_Div_Count_Id_Prefix:"div_count_",
Div_Property_Value:{
width:["430px","430px"],
height:["auto","auto"],
border:["1px solid black",""],
overflowY:["auto","hidden"],
whiteSpace:["nowrap",""],
backgroundColor:["#F5FFFA","#F5FFFA","#87CEEB"],
display:["none","block","inline"],
styleFloat:["left","right"],
cursor:["default","auto","hand"]
},
Elmt_Type:{
input:"input",
div:"div",
button:"button"
},
Elmt_Event:{
OnClick:"onclick",
OnKeyDown:"onkeydown",
OnKeyUp:"onkeyup"
},
Text_Property:{
Type:["text","submit&#