javascript 常用代码大全

// 打开模式对话框
function doSelectUser(txtId)
{

strFeatures="dialogWidth=500px;dialogHeight=360px;center=yes;middle=yes ;help=no;status=no;scroll=no";
var url,strReturn;

url="selUser.aspx";

strReturn=window.showModalDialog(url,'',strFeatures);

}

// 返回模式对话框的值
function okbtn_onclick()
{
var commstr='';

window.returnValue=commstr;

window.close() ;
}
全屏幕打开 IE 窗口
var winWidth=screen.availWidth ;
var winHeight=screen.availHeight-20;
window.open("main.aspx","surveyWindow","toolbar=no,width="+ winWidth +",height="+ winHeight +",top=0,left=0,scrollbars=yes,resizable=yes,center:yes,statusbars=yes");
break
// 脚本中中使用 xml
function initialize() {
var xmlDoc
var xslDoc

xmlDoc = new ActiveXObject('Microsoft.XMLDOM')
xmlDoc.async = false;

xslDoc = new ActiveXObject('Microsoft.XMLDOM')
xslDoc.async = false;

xmlDoc.load("tree.xml")
xslDoc.load("tree.xsl")

folderTree.innerHTML = xmlDoc.documentElement.transformNode(xslDoc)
}

一、验证类
1 、数字验证内
1.1 整数
1.2 大于 0 的整数 (用于传来的 ID 的验证 )
1.3 负整数的验证
1.4 整数不能大于 iMax
1.5 整数不能小于 iMin
2 、时间类
2.1 短时间,形如 (13:04:06)
2.2 短日期,形如 ( 2003-12-05 )
2.3 长时间,形如 (2003-12-05 13:04:06)
2.4 只有年和月。形如 (2003-05, 或者 2003-5)
2.5 只有小时和分钟 , 形如 (12:03)
3 、表单类
3.1 所有的表单的值都不能为空
3.2 多行文本框的值不能为空。
3.3 多行文本框的值不能超过 sMaxStrleng
3.4 多行文本框的值不能少于 sMixStrleng
3.5 判断单选框是否选择。
3.6 判断复选框是否选择 .
3.7 复选框的全选,多选,全不选,反选
3.8 文件上传过程中判断文件类型
4 、字符类
4.1 判断字符全部由 a-Z 或者是 A-Z 的字字母组成
4.2 判断字符由字母和数字组成。
4.3 判断字符由字母和数字,下划线 , 点号组成 . 且开头的只能是下划线和字母
4.4 字符串替换函数 .Replace();
5 、浏览器类
5.1 判断浏览器的类型
5.2 判断 ie 的版本
5.3 判断客户端的分辨率

6 、结合类
6.1 email 的判断。
6.2 手机号码的验证
6.3 身份证的验证

二、功能类

1 、时间与相关控件类
1.1 日历
1.2 时间控件
1.3 万年历
1.4 显示动态显示时钟效果(文本,如 OA 中时间)
1.5 显示动态显示时钟效果 ( 图像,像手表 )
2 、表单类
2.1 自动生成表单
2.2 动态添加,修改,删除下拉框中的元素
2.3 可以输入内容的下拉框
2.4 多行文本框中只能输入 iMax 文字。如果多输入了,自动减少到 iMax 个文字(多用于短信发送 )

3 、打印类
3.1 打印控件
4 、事件类
4.1 屏蔽右键
4.2 屏蔽所有功能键
4.3 --> 和 <-- F 5 F 11,F9,F1
4.4 屏蔽组合键 ctrl+N
5 、网页设计类
5.1 连续滚动的文字,图片(注意是连续的,两段文字和图片中没有空白出现)
5.2 html 编辑控件类
5.3 颜色选取框控件
5.4 下拉菜单
5.5 两层或多层次的下拉菜单
5.6 仿 IE 菜单的按钮。(效果如 rongshuxa.com 的导航栏目 )
5.7 状态栏, title 栏的动态效果(例子很多,可以研究一下)
5.8 双击后,网页自动滚屏
6 、树型结构。
6.1 asp+SQL 版
6.2 asp+xml+sql 版
6.3 java+sql 或者 java+sql+xml
7 、无边框效果的制作
8 、连动下拉框技术
9 、文本排序
10 ,画图类,含饼、柱、矢量贝滋曲线
11 ,操纵客户端注册表类
12 , DIV 层相关(拖拽、显示、隐藏、移动、增加)
13 , TABLAE 相关 ( 客户端动态增加行列,模拟进度条,滚动列表等 )
14 ,各种

  1<object classid=""> 相关类,如播放器,  flash  与脚本互动等    
  216,  刷新  /  模拟无刷新 异步调用类(  XMLHttp  或  iframe,frame  ) 
  3
  4  
  5一、验证类    
  61  、数字验证内    
  71.1  整数    
  8/^(-|\\+)?\d+$/.test(str)   
  91.2  大于  0  的整数 (用于传来的  ID  的验证  )   
 10/^\d+$/.test(str)   
 111.3  负整数的验证    
 12/^-\d+$/.test(str)   
 132  、时间类    
 142.1  短时间,形如  (13:04:06)   
 15function isTime(str)   
 16{   
 17var a = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/);   
 18if (a == null) {alert('  输入的参数不是时间格式  '); return false;}   
 19if (a[1]&gt;24 || a[3]&gt;60 || a[4]&gt;60)   
 20{   
 21alert("  时间格式不对  ");   
 22return false   
 23}   
 24return true;   
 25}   
 262.2  短日期,形如  (  2003-12-05  )   
 27function strDateTime(str)   
 28{   
 29var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);   
 30if(r==null)return false;   
 31var d= new Date(r[1], r[3]-1, r[4]);   
 32return (d.getFullYear()==r[1]&amp;&amp;(d.getMonth()+1)==r[3]&amp;&amp;d.getDate()==r[4]);   
 33}   
 342.3  长时间,形如  (2003-12-05 13:04:06)   
 35function strDateTime(str)   
 36{   
 37var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;   
 38var r = str.match(reg);   
 39if(r==null)return false;   
 40var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);   
 41return (d.getFullYear()==r[1]&amp;&amp;(d.getMonth()+1)==r[3]&amp;&amp;d.getDate()==r[4]&amp;&amp;d.getHours()==r[5]&amp;&amp;d.getMinutes()==r[6]&amp;&amp;d.getSeconds()==r[7]);   
 42}   
 432.4  只有年和月。形如  (2003-05,  或者  2003-5)   
 442.5  只有小时和分钟  ,  形如  (12:03)   
 453  、表单类    
 463.1  所有的表单的值都不能为空    
 47<input onblur="if(this.value.replace(/^\s+|\s+$/g,'')=='')alert('  不能为空  !')"/>   
 483.2  多行文本框的值不能为空。    
 493.3  多行文本框的值不能超过  sMaxStrleng   
 503.4  多行文本框的值不能少于  sMixStrleng   
 513.5  判断单选框是否选择。    
 523.6  判断复选框是否选择  .   
 533.7  复选框的全选,多选,全不选,反选    
 543.8  文件上传过程中判断文件类型    
 554  、字符类    
 564.1  判断字符全部由  a-Z  或者是  A-Z  的字字母组成    
 57<input onblur="if(/[^a-zA-Z]/g.test(this.value))alert('  有错  ')"/>   
 584.2  判断字符由字母和数字组成。    
 59<input onblur="if(/[^0  -9a  -zA-Z]/g.test(this.value))alert('  有错  ')"/>   
 604.3  判断字符由字母和数字,下划线  ,  点号组成  .  且开头的只能是下划线和字母    
 61/^([a-zA-z_]{1})([\w]*)$/g.test(str)   
 624.4  字符串替换函数  .Replace();   
 635  、浏览器类    
 645.1  判断浏览器的类型    
 65window.navigator.appName   
 665.2  判断  ie  的版本    
 67window.navigator.appVersion   
 685.3  判断客户端的分辨率    
 69window.screen.height; window.screen.width;   
 70  
 716  、结合类    
 726.1 email  的判断。    
 73function ismail(mail)   
 74{   
 75return(new RegExp(/^\w+((-\w+)|(\\.\w+))*\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$/).test(mail));   
 76}   
 776.2  手机号码的验证    
 786.3  身份证的验证    
 79function isIdCardNo(num)   
 80{   
 81if (isNaN(num)) {alert("  输入的不是数字!  "); return false;}   
 82var len = num.length, re;   
 83if (len == 15)   
 84re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/);   
 85else if (len == 18)   
 86re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\d)$/);   
 87else {alert("  输入的数字位数不对!  "); return false;}   
 88var a = num.match(re);   
 89if (a != null)   
 90{   
 91if (len==15)   
 92{   
 93var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);   
 94var B = D.getYear()==a[3]&amp;&amp;(D.getMonth()+1)==a[4]&amp;&amp;D.getDate()==a[5];   
 95}   
 96else   
 97{   
 98var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);   
 99var B = D.getFullYear()==a[3]&amp;&amp;(D.getMonth()+1)==a[4]&amp;&amp;D.getDate()==a[5];   
100}   
101if (!B) {alert("  输入的身份证号  "+ a[0] +"  里出生日期不对!  "); return false;}   
102}   
103return true;   
104} 
105
106画图  :   
107<object classid="clsid:  369303C  2-D  7AC  -11D0-89D5  -00A  0C  90833E6" height="240" id="S" style="LEFT: 0px; WIDTH: 392px; TOP: 0px; HEIGHT: 240px" width="392">
108</object>
109<script>   
110S.DrawingSurface.ArcDegrees(0,0,0,30,50,60);   
111S.DrawingSurface.ArcRadians(30,0,0,30,50,60);   
112S.DrawingSurface.Line(10,10,100,100);   
113</script>   
114  
115写注册表:    
116<script>   
117var WshShell = WScript.CreateObject("WScript.Shell");   
118WshShell.RegWrite ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\", 1, "REG_BINARY");   
119WshShell.RegWrite ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\MindReader", "Goocher!", "REG_SZ");   
120var bKey = WshShell.RegRead ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\");   
121WScript.Echo (WshShell.RegRead ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\MindReader"));   
122WshShell.RegDelete ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\MindReader");   
123WshShell.RegDelete ("HKCU\\\Software\\\ACME\\\FortuneTeller\\\");   
124WshShell.RegDelete ("HKCU\\\Software\\\ACME\\\");   
125</script>
126
127TABLAE  相关  (  客户端动态增加行列)    
128<html>
129<script language="JScript">   
130function numberCells() {   
131var count=0;   
132for (i=0; i < document.all.mytable.rows.length; i++) {   
133for (j=0; j < document.all.mytable.rows(i).cells.length; j++) {   
134document.all.mytable.rows(i).cells(j).innerText = count;   
135count++;   
136}   
137}   
138}   
139</script>
140<body onload="numberCells()">
141<table border="1" id="mytable">
142<tr><th> </th><th> </th><th> </th><th> </th></tr>
143<tr><td> </td><td> </td><td> </td><td> </td></tr>
144<tr><td> </td><td> </td><td> </td><td> </td></tr>
145</table>
146</body>
147</html>
148
1491.身份证严格验证: 
150
151<script>   
152var aCity={11:"  北京  ",12:"  天津  ",13:"  河北  ",14:"  山西  ",15:"  内蒙古  ",21:"  辽宁  ",22:"  吉林  ",23:"  黑龙江  ",31:"  上海  ",32:"  江苏  ",33:"  浙江  ",34:"  安徽  ",35:"  福建  ",36:"  江西  ",37:"  山东  ",41:"  河南  ",42:"  湖北  ",43:"  湖南  ",44:"  广东  ",45:"  广西  ",46:"  海南  ",50:"  重庆  ",51:"  四川  ",52:"  贵州  ",53:"  云南  ",54:"  西藏  ",61:"  陕西  ",62:"  甘肃  ",63:"  青海  ",64:"  宁夏  ",65:"  新疆  ",71:"  台湾  ",81:"  香港  ",82:"  澳门  ",91:"  国外  "}   
153  
154function cidInfo(sId){   
155var iSum=0   
156var info=""   
157if(!/^\d{17}(\d|x)$/i.test(sId))return false;   
158sId=sId.replace(/x$/i,"a");   
159if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:  非法地区  ";   
160sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));   
161var d=new Date(sBirthday.replace(/-/g,"/"))   
162if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:  非法生日  ";   
163for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)   
164if(iSum%11!=1)return "Error:  非法证号  ";   
165return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"  男  ":"  女  ")   
166} 
167
168document.write(cidInfo("380524198002300016"),"
169");   
170document.write(cidInfo("340524198002300019"),"
171")   
172document.write(cidInfo("340524197711111111"),"
173")   
174document.write(cidInfo("34052419800101001x"),"
175");   
176</script>
177
1782.验证IP地址    
179<script language="JavaScript">   
180function isip(s){   
181var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};   
182var re=s.split(".")   
183return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false   
184} 
185
186var s="202.197.78.129";   
187alert(isip(s))   
188</script>
189
1903.加  sp1  后还能用的无边框窗口!!    
191<html xmlns:ie="">
192<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
193<ie:download id="include" style="behavior:url(#default#download)"></ie:download>
194<title>Chromeless Window</title>
195<script language="JScript">   
196/*--- Special Thanks For andot ---*/ 
197
198/*   
199This following code are designed and writen by Windy_sk < [email protected]  >   
200You can use it freely, but u must held all the copyright items!   
201*/ 
202
203/*--- Thanks For andot Again ---*/ 
204
205var CW_width= 400;   
206var CW_height= 300;   
207var CW_top= 100;   
208var CW_left= 100;   
209var CW_url= "/";   
210var New_CW= window.createPopup();   
211var CW_Body= New_CW.document.body;   
212var content= "";   
213var CSStext= "margin:1px;color:black; border:2px outset;border-style:expression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'}, onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;"; 
214
215//Build Window   
216include.startDownload(CW_url, function(source){content=source}); 
217
218function insert_content(){   
219var temp = "";   
220CW_Body.style.overflow= "hidden";   
221CW_Body.style.backgroundColor= "white";   
222CW_Body.style.border= "solid black 1px";   
223content = content.replace(/<a ([^>]*)>/g,"<a onclick='parent.open(this.href);return false' $1>");   
224temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";   
225temp += "<tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' ondblclick=\"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" onmouseup='parent.drag_up(event)' onmousemove='parent.drag_move(event)' onmousedown='parent.drag_down(event)' onselectstart='return false' oncontextmenu='return false'>";   
226temp += "<td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>";   
227temp += "<td style='color:#ffffff;padding-right:5px;' align=right>";   
228temp += "<span id=Help onclick=\"alert('Chromeless Window For IE6 SP1 - Ver 1.0\\\n\\\nCode By Windy_sk\\\n\\\nSpecial Thanks For andot')\" style=\""+CSStext+"font-family:System;padding-right:2px;\">?</span>";   
229temp += "<span id=Min onclick='parent.New_CW.hide();parent.blur()' style=\""+CSStext+"font-family:Webdings;\" title='Minimum'>0</span>";   
230temp += "<span id=Max onclick=\"this.innerText=this.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" style=\""+CSStext+"font-family:Webdings;\" title='Maximum'>1</span>";   
231temp += "<span id=Close onclick='parent.opener=null;parent.close()' style=\""+CSStext+"font-family:System;padding-right:2px;\" title='Close'>x</span>";   
232temp += "</td></tr><tr><td colspan=2>";   
233temp += "<div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:"+CW_width+"'>";   
234temp += content;   
235temp += "</div>";   
236temp += "</td></tr></table>";   
237CW_Body.innerHTML = temp;   
238} 
239
240setTimeout("insert_content()",1000); 
241
242var if_max = true;   
243function show_CW(){   
244window.moveTo(10000, 10000);   
245if(if_max){   
246New_CW.show(CW_top, CW_left, CW_width, CW_height);   
247if(typeof(New_CW.document.all.include)!="undefined"){   
248New_CW.document.all.include.style.width = CW_width;   
249New_CW.document.all.Max.innerText = "1";   
250} 
251
252}else{   
253New_CW.show(0, 0, screen.width, screen.height);   
254New_CW.document.all.include.style.width = screen.width;   
255}   
256} 
257
258window.onfocus = show_CW;   
259window.onresize = show_CW; 
260
261// Move Window   
262var drag_x,drag_y,draging=false 
263
264function drag_move(e){   
265if (draging){   
266New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);   
267return false;   
268}   
269} 
270
271function drag_down(e){   
272if(e.button==2)return;   
273if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;   
274drag_x=e.clientX;   
275drag_y=e.clientY;   
276draging=true;   
277e.srcElement.setCapture();   
278} 
279
280function drag_up(e){   
281draging=false;   
282e.srcElement.releaseCapture();   
283if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;   
284CW_top = e.screenX-drag_x;   
285CW_left = e.screenY-drag_y;   
286} 
287
288</script>
289</html>
290
291  
292  
293贴两个关于  treeview  的    
294<script language="javascript">   
295<!--   
296//  初始化选中节点    
297function initchecknode()   
298{   
299var node=TreeView1.getTreeNode("1");   
300node.setAttribute("Checked","true");   
301setcheck(node,"true");   
302FindCheckedFromNode(TreeView1);   
303}   
304//oncheck  事件    
305function tree_oncheck(tree)   
306{   
307var node=tree.getTreeNode(tree.clickedNodeIndex);   
308var Pchecked=tree.getTreeNode(tree.clickedNodeIndex).getAttribute("checked");   
309setcheck(node,Pchecked);   
310document.all.checked.value="";   
311document.all.unchecked.value="";   
312FindCheckedFromNode(TreeView1);   
313}   
314//  设置子节点选中    
315function setcheck(node,Pc)   
316{   
317var i;   
318var ChildNode=new Array();   
319ChildNode=node.getChildren();   
320  
321if(parseInt(ChildNode.length)==0)   
322return;   
323else   
324{   
325for(i=0;i<ChildNode.length;i++)   
326{   
327var cNode;   
328cNode=ChildNode[i];   
329if(parseInt(cNode.getChildren().length)!=0)   
330setcheck(cNode,Pc);   
331cNode.setAttribute("Checked",Pc);   
332}   
333}   
334}   
335//  获取所有节点状态    
336function FindCheckedFromNode(node) {   
337var i = 0;   
338var nodes = new Array();   
339nodes = node.getChildren();   
340  
341for (i = 0; i < nodes.length; i++) {   
342var cNode;   
343cNode=nodes[i];   
344if (cNode.getAttribute("Checked"))   
345AddChecked(cNode);   
346else   
347AddUnChecked(cNode);   
348  
349if (parseInt(cNode.getChildren().length) != 0 ) {   
350FindCheckedFromNode(cNode);   
351}   
352}   
353}   
354//  添加选中节点    
355function AddChecked(node) {   
356document.all.checked.value += node.getAttribute("NodeData");   
357document.all.checked.value += ',';   
358}   
359//  添加未选中节点    
360function AddUnChecked(node) {   
361document.all.unchecked.value += node.getAttribute("NodeData");   
362document.all.unchecked.value += ',';   
363}   
364//-->   
365</script>
366
367  
368  
369treeview  中如何在服务器端得到客户端设置后的节点选中状态    
370<script language="C#" runat="server">   
371private void Button1_Click(object sender, System.EventArgs e)   
372{   
373Response.Write(TreeView1.Nodes[0].Checked);   
374}   
375</script>
376<script language="javascript">   
377function set_check()   
378{   
379var nodeindex = "0";   
380var node=TreeView1.getTreeNode(nodeindex);   
381node.setAttribute("Checked","True");   
382TreeView1.queueEvent('oncheck', nodeindex);   
383}   
384</script>
385
386  
387  
388三個實用的小技巧  :  關閉輸入法  .  禁止貼上  .  禁止複製    
389關閉輸入法 
390
391本文字框輸入法被關閉:    
392語法:  style="ime-mode:disabled"   
393範例:  <input name="textfield" style="ime-mode:disabled" type="text"/>
394
395禁止貼上 
396
397本文字框禁止貼上文字:    
398語法:  onpaste="return false"   
399範例:  <input name="textfield" onpaste="return false" type="text"/>
400
401禁止複製 
402
403本文字框禁止複製:    
404語法:  oncopy="return false;" oncut="return false;"   
405範例:  <input name="textfield" oncopy="return false;" oncut="return false;" type="text" value="  不能複製裡面的字  "/>
406
407  
408  
409//================================   
410//Cookie  操作    
411//================================   
412function getCookieVal (offset)   
413{   
414var endstr = document.cookie.indexOf (";", offset);   
415if (endstr == -1)   
416endstr = document.cookie.length;   
417return unescape(document.cookie.substring(offset, endstr));   
418} 
419
420function GetCookie (name)   
421{   
422var arg = name + "=";   
423var alen = arg.length;   
424var clen = document.cookie.length;   
425var i = 0;   
426while (i &lt; clen)   
427{   
428var j = i + alen;   
429if (document.cookie.substring(i, j) == arg)   
430return getCookieVal (j);   
431i = document.cookie.indexOf(" ", i) + 1;   
432if (i == 0)   
433break;   
434}   
435return null;   
436} 
437
438  
439function deleteCookie(cname) { 
440
441var expdate = new Date();   
442expdate.setTime(expdate.getTime() - (24 * 60 * 60 * 1000 * 369)); 
443
444// document.cookie =" ckValue="ok"; expires="+ expdate.toGMTString();   
445setCookie(cname,"",expdate); 
446
447} 
448
449function setCookie (name, value, expires) { 
450
451document.cookie = name + "=" + escape(value) +   
452"; expires=" + expires.toGMTString() ;   
453} 
454
455  
456  
457一个可以在页面上随意画线、多边形、圆,填充等功能的  js  (  part 1  ) 
458
459var jg_ihtm, jg_ie, jg_fast, jg_dom, jg_moz,   
460jg_n4 = (document.layers &amp;&amp; typeof document.classes != "undefined"); 
461
462  
463function chkDHTM(x, i)   
464{   
465x = document.body || null;   
466jg_ie = x &amp;&amp; typeof x.insertAdjacentHTML != "undefined";   
467jg_dom = (x &amp;&amp; !jg_ie &amp;&amp;   
468typeof x.appendChild != "undefined" &amp;&amp;   
469typeof document.createRange != "undefined" &amp;&amp;   
470typeof (i = document.createRange()).setStartBefore != "undefined" &amp;&amp;   
471typeof i.createContextualFragment != "undefined");   
472jg_ihtm = !jg_ie &amp;&amp; !jg_dom &amp;&amp; x &amp;&amp; typeof x.innerHTML != "undefined";   
473jg_fast = jg_ie &amp;&amp; document.all &amp;&amp; !window.opera;   
474jg_moz = jg_dom &amp;&amp; typeof x.style.MozOpacity != "undefined";   
475} 
476
477  
478function pntDoc()   
479{   
480this.wnd.document.write(jg_fast? this.htmRpc() : this.htm);   
481this.htm = '';   
482} 
483
484  
485function pntCnvDom()   
486{   
487var x = document.createRange();   
488x.setStartBefore(this.cnv);   
489x = x.createContextualFragment(jg_fast? this.htmRpc() : this.htm);   
490this.cnv.appendChild(x);   
491this.htm = '';   
492} 
493
494  
495function pntCnvIe()   
496{   
497this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this.htmRpc() : this.htm);   
498this.htm = '';   
499} 
500
501  
502function pntCnvIhtm()   
503{   
504this.cnv.innerHTML += this.htm;   
505this.htm = '';   
506} 
507
508  
509function pntCnv()   
510{   
511this.htm = '';   
512} 
513
514  
515function mkDiv(x, y, w, h)   
516{   
517this.htm += '<div style="position:absolute;'+   
518'left:' + x + 'px;'+   
519'top:' + y + 'px;'+   
520'width:' + w + 'px;'+   
521'height:' + h + 'px;'+   
522'clip:rect(0,'+w+'px,'+h+'px,0);'+   
523'background-color:' + this.color +   
524(!jg_moz? ';overflow:hidden' : '')+   
525';">&lt;\/div&gt;';   
526} 
527
528  
529function mkDivIe(x, y, w, h)   
530{   
531this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';   
532} 
533
534  
535function mkDivPrt(x, y, w, h)   
536{   
537this.htm += '<div style="position:absolute;'+   
538'border-left:' + w + 'px solid ' + this.color + ';'+   
539'left:' + x + 'px;'+   
540'top:' + y + 'px;'+   
541'width:0px;'+   
542'height:' + h + 'px;'+   
543'clip:rect(0,'+w+'px,'+h+'px,0);'+   
544'background-color:' + this.color +   
545(!jg_moz? ';overflow:hidden' : '')+   
546';">&lt;\/div&gt;';   
547} 
548
549&lt;p class="MsoNormal" style="BACKG</div></div></object>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus