﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-登陆不起啦(aiut) Thingking in B/S-随笔分类-Javascript 研究</title><link>http://www.cnitblog.com/aiut/category/1002.html</link><description /><language>zh-cn</language><lastBuildDate>Sat, 01 Oct 2011 11:54:01 GMT</lastBuildDate><pubDate>Sat, 01 Oct 2011 11:54:01 GMT</pubDate><ttl>60</ttl><item><title>转帖-document.execCommand() 解析</title><link>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Thu, 20 Oct 2005 02:50:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3422.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3422.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3422.html</trackback:ping><description><![CDATA[功能的确很多哦。<BR><BR>2D-Position 允许通过拖曳移动绝对定位的对象。 <BR>AbsolutePosition 设定元素的 position 属性为“absolute”(绝对)。 <BR>BackColor 设置或获取当前选中区的背景颜色。 <BR>BlockDirLTR 目前尚未支持。 <BR>BlockDirRTL 目前尚未支持。 <BR>Bold 切换当前选中区的粗体显示与否。 <BR>BrowseMode 目前尚未支持。 <BR>Copy 将当前选中区复制到剪贴板。 <BR>CreateBookmark 创建一个书签锚或获取当前选中区或插入点的书签锚的名称。 <BR>CreateLink 在当前选中区上插入超级链接，或显示一个对话框允许用户指定要为当前选中区插入的超级链接的 URL。 <BR>Cut 将当前选中区复制到剪贴板并删除之。 <BR>Delete 删除当前选中区。 <BR>DirLTR 目前尚未支持。 <BR>DirRTL 目前尚未支持。 <BR>EditMode 目前尚未支持。 <BR>FontName 设置或获取当前选中区的字体。 <BR>FontSize 设置或获取当前选中区的字体大小。 <BR>ForeColor 设置或获取当前选中区的前景(文本)颜色。 <BR>FormatBlock 设置当前块格式化标签。 <BR>Indent 增加选中文本的缩进。 <BR>InlineDirLTR 目前尚未支持。 <BR>InlineDirRTL 目前尚未支持。 <BR>InsertButton 用按钮控件覆盖当前选中区。 <BR>InsertFieldset 用方框覆盖当前选中区。 <BR>InsertHorizontalRule 用水平线覆盖当前选中区。 <BR>InsertIFrame 用内嵌框架覆盖当前选中区。 <BR>InsertImage 用图像覆盖当前选中区。 <BR>InsertInputButton 用按钮控件覆盖当前选中区。 <BR>InsertInputCheckbox 用复选框控件覆盖当前选中区。 <BR>InsertInputFileUpload 用文件上载控件覆盖当前选中区。 <BR>InsertInputHidden 插入隐藏控件覆盖当前选中区。 <BR>InsertInputImage 用图像控件覆盖当前选中区。 <BR>InsertInputPassword 用密码控件覆盖当前选中区。 <BR>InsertInputRadio 用单选钮控件覆盖当前选中区。 <BR>InsertInputReset 用重置控件覆盖当前选中区。 <BR>InsertInputSubmit 用提交控件覆盖当前选中区。 <BR>InsertInputText 用文本控件覆盖当前选中区。 <BR>InsertMarquee 用空字幕覆盖当前选中区。 <BR>InsertOrderedList 切换当前选中区是编号列表还是常规格式化块。 <BR>InsertParagraph 用换行覆盖当前选中区。 <BR>InsertSelectDropdown 用下拉框控件覆盖当前选中区。 <BR>InsertSelectListbox 用列表框控件覆盖当前选中区。 <BR>InsertTextArea 用多行文本输入控件覆盖当前选中区。 <BR>InsertUnorderedList 切换当前选中区是项目符号列表还是常规格式化块。 <BR>Italic 切换当前选中区斜体显示与否。 <BR>JustifyCenter 将当前选中区在所在格式化块置中。 <BR>JustifyFull 目前尚未支持。 <BR>JustifyLeft 将当前选中区所在格式化块左对齐。 <BR>JustifyNone 目前尚未支持。 <BR>JustifyRight 将当前选中区所在格式化块右对齐。 <BR>LiveResize 迫使 MSHTML 编辑器在缩放或移动过程中持续更新元素外观，而不是只在移动或缩放完成后更新。 <BR>MultipleSelection 允许当用户按住 Shift 或 Ctrl 键时一次选中多于一个站点可选元素。 <BR>Open 打开。 <BR>Outdent 减少选中区所在格式化块的缩进。 <BR>OverWrite 切换文本状态的插入和覆盖。 <BR>Paste 用剪贴板内容覆盖当前选中区。 <BR>PlayImage 目前尚未支持。 <BR>Print 打开打印对话框以便用户可以打印当前页。 <BR>Redo 重做。 <BR>Refresh 刷新当前文档。 <BR>RemoveFormat 从当前选中区中删除格式化标签。 <BR>RemoveParaFormat 目前尚未支持。 <BR>SaveAs 将当前 Web 页面保存为文件。 <BR>SelectAll 选中整个文档。 <BR>SizeToControl 目前尚未支持。 <BR>SizeToControlHeight 目前尚未支持。 <BR>SizeToControlWidth 目前尚未支持。 <BR>Stop 停止。 <BR>StopImage 目前尚未支持。 <BR>StrikeThrough 目前尚未支持。 <BR>Subscript 目前尚未支持。 <BR>Superscript 目前尚未支持。 <BR>UnBookmark 从当前选中区中删除全部书签。 <BR>Underline 切换当前选中区的下划线显示与否。 <BR>Undo 撤消。 <BR>Unlink 从当前选中区中删除全部超级链接。 <BR>Unselect 清除当前选中区的选中状态。 <img src ="http://www.cnitblog.com/aiut/aggbug/3422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-20 10:50 <a href="http://www.cnitblog.com/aiut/archive/2005/10/20/3422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用XMLHTTP无刷新添加数据之Post篇(转载)</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 06:08:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3312.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3312.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3312.html</trackback:ping><description><![CDATA[<P>&nbsp;</P>
<P>我们传统的提交数据的方法都是用&lt;Form&gt;来实现的.<BR>&lt;Form&gt;标记中的Method属性确定了表单元素的数据在发送到服务器时,<BR>如何对HTTP请求信息进行打包. <BR>Method 属性可以使用的方法<BR>Method属性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 发送表单元素的方式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 读取数据的Request集合<BR>Get&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 标识在URL的最后&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueryString<BR>Post&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在HTTP请求的主体内(HTTP请求的自由区域)&nbsp; Form</P>
<P><BR>这篇文章用XMLHTTP来实现Form的Method=Post.<BR><BR><FONT color=#ff0000>ClientPost.htm<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="JavaScript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;AddDataPost(sUserId,sUserName)<BR>{<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">/*</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;*---------------&nbsp;AddDataPost(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;*&nbsp;AddDataPost(sUserId,sUserName)&nbsp;<BR>&nbsp;*&nbsp;功能:通过XMLHTTP添加数据.相当于Form的Method=Post.<BR>&nbsp;*&nbsp;参数:sUserId,字符串,发送条件.<BR>&nbsp;*&nbsp;参数:sUserName,字符串,发送条件.<BR>&nbsp;*&nbsp;实例:AddDataPost(document.all.userid.value,document.all.username.value);<BR>&nbsp;*---------------&nbsp;AddDataPost(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">*/</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;oBao&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Microsoft.XMLHTTP</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">特殊字符：+,%,&amp;,=,?等的传输解决办法.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">escape(sUserId),escape(sUserName);</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;sUserId&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;escape(sUserId);<BR>&nbsp;&nbsp;&nbsp;&nbsp;sUserName&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;escape(sUserName);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;userInfo&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">userid=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sUserId</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;username=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">sUserName;<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.open(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">POST</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Server.asp</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.setRequestHeader(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Content-Type</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">application/x-www-form-urlencoded</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.send(userInfo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">清空输入框数据.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;document.all.userid.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;document.all.username.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">服务器端处理返回的是经过escape编码的字符串.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;alert(unescape(oBao.responseText))<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="button"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;onclick</SPAN><SPAN style="COLOR: #0000ff">="AddDataPost(document.all.userid.value,document.all.username.value)"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="AddDataPost"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>userid:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="userid"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>username:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="username"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV></FONT><BR><FONT color=#ff0000>Server.asp&nbsp; 服务器端处理.<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">&nbsp;@Language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">JavaScript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(sdbname)<BR>{<BR></SPAN><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;*&nbsp;OpenDB(sdbname)&nbsp;<BR>&nbsp;*&nbsp;功能:打开数据库sdbname,返回conn对象.<BR>&nbsp;*&nbsp;参数:sdbname,字符串,数据库名称.<BR>&nbsp;*&nbsp;实例:var&nbsp;conn&nbsp;=&nbsp;OpenDB("database.mdb");<BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;connstr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Provider=Microsoft.Jet.OLEDB.4.0;&nbsp;Data&nbsp;Source=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">Server.MapPath(sdbname);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;conn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Server.CreateObject(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ADODB.Connection</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;conn.Open(connstr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;conn;<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;oConn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">data.mdb</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Post.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Post.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">特殊字符：+,%,&amp;,=,?等的传输解决办法.客户端传输过来是经过escape编码的.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">所以服用器端应该先unescape解码.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">unescape(Request.Form("userid"))<IMG src="http://www.cnitblog.com/images/dot.gif">..</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;userid&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.Form(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;username&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.Form(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR>sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\nusername:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\n&nbsp;添加成功.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sql&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Insert&nbsp;into&nbsp;users(userid,username)Values('</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">','</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">')</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>oConn.Execute(sql);<BR>Response.Write(escape(sResult));<BR></SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN></DIV>
<P></FONT><FONT color=#000000>数据库设计<BR>data.mdb<BR>表users.<BR>字段<BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 自动编号<BR>userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本<BR>username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本</FONT></P>
<P><FONT color=#000000>表:users 数据: <BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username<BR>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wanghr100&nbsp;&nbsp; 管理员</FONT></P><img src ="http://www.cnitblog.com/aiut/aggbug/3312.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 14:08 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3312.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用XMLHTTP无刷新添加数据之Get篇(转载)</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3311.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 05:54:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3311.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3311.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3311.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3311.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3311.html</trackback:ping><description><![CDATA[<P>转载关于XmlHttp的介绍<BR>---------------------------------<BR><BR>我们传统的提交数据的方法都是用&lt;Form&gt;来实现的.<BR>&lt;Form&gt;标记中的Method属性确定了表单元素的数据在发送到服务器时,<BR>如何对HTTP请求信息进行打包. <BR>Method 属性可以使用的方法<BR>Method属性&nbsp;&nbsp; 发送表单元素的方式&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 读取数据的Request集合<BR>Get&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 标识在URL的最后&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QueryString<BR>Post&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在HTTP请求的主体内(HTTP请求的自由区域)&nbsp; Form</P>
<P><BR>这篇文章用XMLHTTP来实现Form的Method=Get.<BR><BR><FONT face=Verdana color=#ff0000>ClientGet.htm<BR><BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="JavaScript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;AddDataGet(sUserId,sUserName)<BR>{<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">/*</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;*---------------&nbsp;AddDataGet(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;*&nbsp;AddDataGet(sUserId,sUserName)&nbsp;<BR>&nbsp;*&nbsp;功能:通过XMLHTTP添加数据.相当于Form的Method=Get.<BR>&nbsp;*&nbsp;参数:sUserId,字符串,发送条件.<BR>&nbsp;*&nbsp;参数:sUserName,字符串,发送条件.<BR>&nbsp;*&nbsp;实例:AddDataGet(document.all.userid.value,document.all.username.value);<BR>&nbsp;*---------------&nbsp;AddDataGet(sUserId,sUserName)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">*/</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;oBao&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;ActiveXObject(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Microsoft.XMLHTTP</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">特殊字符：+,%,&amp;,=,?等的传输解决办法.用escape编码.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">escape(sUserId),escape(sUserName);</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;oBao.open(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">POST</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">,</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Server.asp?userid=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">escape(sUserId)</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&amp;username=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">+</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">escape(sUserName),</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">false</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;oBao.send();<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">清空输入框数据.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;document.all.userid.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;document.all.username.value</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">服务器端处理返回的是经过escape编码的字符串.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;alert(unescape(oBao.responseText))<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="button"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;onclick</SPAN><SPAN style="COLOR: #0000ff">="AddDataGet(document.all.userid.value,document.all.username.value)"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">="AddDataGet"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>userid:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="userid"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>username:</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="username"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV></FONT><BR><BR><FONT color=#ff0000>Server.asp&nbsp; 服务器端处理.<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000">&nbsp;@Language</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">JavaScript</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #000000">&lt;%</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">function</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(sdbname)<BR>{<BR></SPAN><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;*&nbsp;OpenDB(sdbname)&nbsp;<BR>&nbsp;*&nbsp;功能:打开数据库sdbname,返回conn对象.<BR>&nbsp;*&nbsp;参数:sdbname,字符串,数据库名称.<BR>&nbsp;*&nbsp;实例:var&nbsp;conn&nbsp;=&nbsp;OpenDB("database.mdb");<BR>&nbsp;*---------------&nbsp;OpenDB(sdbname)&nbsp;-----------------<BR>&nbsp;</SPAN><SPAN style="COLOR: #008000">*/</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;connstr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Provider=Microsoft.Jet.OLEDB.4.0;&nbsp;Data&nbsp;Source=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">Server.MapPath(sdbname);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;conn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Server.CreateObject(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ADODB.Connection</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;conn.Open(connstr);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;conn;<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;oConn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;OpenDB(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">data.mdb</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Get.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">相当于Form的Method=Get.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">特殊字符：+,%,&amp;,=,?等的传输解决办法.客户端传输过来是经过escape编码的.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">所以服用器端应该先用unescape解码.</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">Update:2004-6-1&nbsp;12:22</SPAN><SPAN style="COLOR: #008000"><BR>//</SPAN><SPAN style="COLOR: #008000">unescape(Request.QueryString("userid"))<IMG src="http://www.cnitblog.com/images/dot.gif">..</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;userid&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.QueryString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;username&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;unescape(Request.QueryString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR>sResult&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">userid:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\nusername:</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\n&nbsp;添加成功.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">var</SPAN><SPAN style="COLOR: #000000">&nbsp;sql&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Insert&nbsp;into&nbsp;users(userid,username)Values('</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">userid</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">','</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">username</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">')</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>oConn.Execute(sql);<BR>Response.Write(escape(sResult));<BR></SPAN><SPAN style="COLOR: #000000">%&gt;</SPAN></DIV>
<P></FONT><FONT color=#000000>数据库设计<BR>data.mdb<BR>表users.<BR>字段<BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 自动编号<BR>userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本<BR>username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 文本</FONT></P>
<P><FONT color=#000000>表:users 数据: <BR>id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username<BR>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wanghr100&nbsp;&nbsp;&nbsp; 管理员</FONT></P><img src ="http://www.cnitblog.com/aiut/aggbug/3311.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 13:54 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3311.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>js的称重游戏</title><link>http://www.cnitblog.com/aiut/archive/2005/10/15/3310.html</link><dc:creator>登陆不起啦</dc:creator><author>登陆不起啦</author><pubDate>Sat, 15 Oct 2005 05:08:00 GMT</pubDate><guid>http://www.cnitblog.com/aiut/archive/2005/10/15/3310.html</guid><wfw:comment>http://www.cnitblog.com/aiut/comments/3310.html</wfw:comment><comments>http://www.cnitblog.com/aiut/archive/2005/10/15/3310.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/aiut/comments/commentRss/3310.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/aiut/services/trackbacks/3310.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 前段时间写的称重游戏。哈哈保存保存。&lt;style&gt;.box{position:absolute;width:25px;height:25px;z-index:9;filter&nbsp;:&nbsp;progid:DXImageTransform.Microsoft.gradient(startColorStr=#80FCFCFC,endColorStr=#FFC3C3C3);bo...&nbsp;&nbsp;<a href='http://www.cnitblog.com/aiut/archive/2005/10/15/3310.html'>阅读全文</a><img src ="http://www.cnitblog.com/aiut/aggbug/3310.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/aiut/" target="_blank">登陆不起啦</a> 2005-10-15 13:08 <a href="http://www.cnitblog.com/aiut/archive/2005/10/15/3310.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>