⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comment.htm

📁 17个C源程序分享
💻 HTM
字号:

   function xmlhttp()
	{
		var A=null;
		try
		{
			A=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				A=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(oc)
			{
				if (typeof XMLHttpRequest != "undefined" );
				{
					A=new XMLHttpRequest();
				}
			}
		}			
		return A;
	}
	
var loader=new xmlhttp;
function ajaxLoadPage(url,request,method,fun)
{
	method=method.toUpperCase();
	if (method=='GET')
	{
		urls=url.split("?");
		if (urls[1]=='' || typeof urls[1]=='undefined')
		{
			url=urls[0]+"?"+request;
		}
		else
		{
			url=urls[0]+"?"+urls[1]+"&"+request;
		}
		
		request=null;
	}
	loader.open(method,url,true);
	if (method=="POST")
	{
		loader.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	}
	loader.onreadystatechange=function(){
	     eval(fun+'()');
	}
	loader.send(request);
}

function formToRequestString(form_obj)
{
    var query_string='';
    var and='';
    for (var i=0;i<form_obj.length;i++ )
    {
        e=form_obj[i];
        if (e.name) {
            if (e.type=='select-one') {
                element_value=e.options[e.selectedIndex].value;
            } else if (e.type=='select-multiple') {
                for (var n=0;n<e.length;n++) {
                    var op=e.options[n];
                    if (op.selected) {
                        query_string+=and+e.name+'='+escape(op.value);
                        and="&"
                    }
                }
                continue;
            } else if (e.type=='checkbox' || e.type=='radio') {
                if (e.checked==false) {   
                    continue;   
                }   
                element_value=e.value;
            } else if (typeof e.value != 'undefined') {
                element_value=e.value;
            } else {
                continue;
            }
            query_string+=and+e.name+'='+escape(element_value);
            and="&"
        }
    }
    return query_string;
}
function ajaxFormSubmit(form_obj,fun)
{ 
	ajaxLoadPage(form_obj.getAttributeNode("action").value,formToRequestString(form_obj),form_obj.method,fun)
}
 
	function insertface(Val)
	{ 
	  
	  checklength(document.getElementById('C_Content'));
	  
		  if (Val!=''){
		   document.getElementById('C_Content').focus();
		   var str = document.selection.createRange();
		   str.text = Val; 
		  }
  }
	
function success()
{
	var loading_msg='\n\n\t请稍等,正在提交评论...';
	var C_Content=document.getElementById('C_Content');
	
 	if (loader.readyState==1)
		{
			C_Content.value=loading_msg;
		}
	if (loader.readyState==4)
		{   var s=loader.responseText;
			if (s=='ok')
			 {
			 alert('恭喜,你的评论已成功提交!');
			  if (typeof(loadDate)!="undefined") loadDate(1);
			  leavePage();
			 }
			else
			 {alert(s);
			  C_Content.value=document.getElementById('sC_Content').value;
			 }
		}
}
	var OutTimes =11;
	function leavePage()
	{
	if (OutTimes==0)
	 {
	 document.getElementById('C_Content').disabled=false;
	 document.getElementById('SubmitComment').disabled=false;
	 document.getElementById('C_Content').value=''
	 
	 document.getElementById('cmax').value=400;
	 
	 OutTimes =11;
	 return;
	 }
	else {
	    document.getElementById('C_Content').disabled=true;
		document.getElementById('SubmitComment').disabled=true;
		OutTimes -= 1;
		document.getElementById('C_Content').value ="\n\n\t评论已提交,等待 "+ OutTimes + " 秒钟后您可继续发表...";
		setTimeout("leavePage()", 1000);
		}
	}
function checklength(cobj)
{
	var cmax=400;
	if (cobj.value.length>cmax) {
	cobj.value = cobj.value.substring(0,cmax);
	alert("评论不能超过"+cmax+"个字符!");
	}
	else {
	document.getElementById('cmax').value = cmax-cobj.value.length;
	}
}

   function checkform()
   {
	var anounname=document.getElementById('AnounName');
	var C_Content=document.getElementById('C_Content');
	var sC_Content=document.getElementById('sC_Content');
	var anonymous=document.getElementById('Anonymous');
	var pass=document.getElementById('Pass');
   if (anounname.value==''){
        alert('请填写用户名。');
		anounname.focus();
        return false;
     }
	if (anonymous.checked==false && pass.value=='')
	{
	   alert('请输入密码或选择游客发表!');
	   pass.focus();
	   return false;
	}
	
   if (C_Content.value==''){
	   alert('请填写评论内容!');
	   C_Content.focus();
	   return false;
    }
	sC_Content.value=C_Content.value;
	ajaxFormSubmit(document.form1,'success')
	}
document.write('<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="comment_write_table"><form name="form1" action="http://www.51hei.com/plus/Comment.asp?Action=WriteSave" method="post"><input type="hidden" value="1" name="ChannelID"><input type="hidden" value="150" name="InfoID"><tr><td height="30" colspan="2" class="comment_write_title">发表评论&nbsp;&nbsp;<font color=#ff6600>特别声明:评论内容只代表网友个人观点,与本站立场无关。</font></td></tr><tr>  <td height="30" colspan="2">&nbsp;用户名:   <input class="textbox" maxlength=15 name="AnounName" type="text" id="AnounName" value="" style="width:12%"/><span id="pp"> 密码:<input class="textbox" name="Pass" size="10" type="password" id="Pass" value="" class="denglu"></span><span><input onclick="if(this.checked==true){document.all.Pass.disabled=true;document.all.pp.style.display=\'none\';}else{document.all.Pass.disabled=false;document.all.pp.style.display=\'\';}" type="checkbox" value="1" name="Anonymous">匿名发表</span>&nbsp;&nbsp;<a href="http://www.51hei.com/User/UserReg.asp"><font color=red><u>注册</u><font></a></td>  </tr>  <tr>    <td width="80%" align="center"><textarea onkeydown="checklength(this);" onkeyup="checklength(this);" name="C_Content" rows="6" id="C_Content" style="width:98%"></textarea></td>    <td height="25" align="center"><img style="cursor:hand" title="惊讶" onclick="insertface(\'[e0]\')"  src="http://www.51hei.com/images/emot/0.gif">&nbsp;<img style="cursor:hand" title="撇嘴" onclick="insertface(\'[e1]\')"  src="http://www.51hei.com/images/emot/1.gif">&nbsp;<img style="cursor:hand" title="色" onclick="insertface(\'[e2]\')"  src="http://www.51hei.com/images/emot/2.gif">&nbsp;<img style="cursor:hand" title="发呆" onclick="insertface(\'[e3]\')"  src="http://www.51hei.com/images/emot/3.gif">&nbsp;<img style="cursor:hand" title="得意" onclick="insertface(\'[e4]\')"  src="http://www.51hei.com/images/emot/4.gif">&nbsp;<br /><img style="cursor:hand" title="流泪" onclick="insertface(\'[e5]\')"  src="http://www.51hei.com/images/emot/5.gif">&nbsp;<img style="cursor:hand" title="害羞" onclick="insertface(\'[e6]\')"  src="http://www.51hei.com/images/emot/6.gif">&nbsp;<img style="cursor:hand" title="闭嘴" onclick="insertface(\'[e7]\')"  src="http://www.51hei.com/images/emot/7.gif">&nbsp;<img style="cursor:hand" title="睡" onclick="insertface(\'[e8]\')"  src="http://www.51hei.com/images/emot/8.gif">&nbsp;<img style="cursor:hand" title="大哭" onclick="insertface(\'[e9]\')"  src="http://www.51hei.com/images/emot/9.gif">&nbsp;<br /><img style="cursor:hand" title="尴尬" onclick="insertface(\'[e10]\')"  src="http://www.51hei.com/images/emot/10.gif">&nbsp;<img style="cursor:hand" title="发怒" onclick="insertface(\'[e11]\')"  src="http://www.51hei.com/images/emot/11.gif">&nbsp;<img style="cursor:hand" title="调皮" onclick="insertface(\'[e12]\')"  src="http://www.51hei.com/images/emot/12.gif">&nbsp;<img style="cursor:hand" title="呲牙" onclick="insertface(\'[e13]\')"  src="http://www.51hei.com/images/emot/13.gif">&nbsp;<img style="cursor:hand" title="微笑" onclick="insertface(\'[e14]\')"  src="http://www.51hei.com/images/emot/14.gif">&nbsp;<br /><img style="cursor:hand" title="难过" onclick="insertface(\'[e15]\')"  src="http://www.51hei.com/images/emot/15.gif">&nbsp;<img style="cursor:hand" title="酷" onclick="insertface(\'[e16]\')"  src="http://www.51hei.com/images/emot/16.gif">&nbsp;<img style="cursor:hand" title="非典" onclick="insertface(\'[e17]\')"  src="http://www.51hei.com/images/emot/17.gif">&nbsp;<img style="cursor:hand" title="抓狂" onclick="insertface(\'[e18]\')"  src="http://www.51hei.com/images/emot/18.gif">&nbsp;<img style="cursor:hand" title="吐" onclick="insertface(\'[e19]\')"  src="http://www.51hei.com/images/emot/19.gif">&nbsp;<br /></td>  </tr>  <tr>    <td height="25" colspan="2" align="center">剩余字数:<input disabled type="text" size="5" name="cmax" value="400">&nbsp;&nbsp;&nbsp;<input type="hidden" name="sC_Content" id="sC_Content"><input type="button" id="SubmitComment" name="SubmitComment" value="提交发表" onclick="checkform();"/>    <a href="http://www.51hei.com/plus/Comment.asp?ChannelID=1&InfoID=150" target="_blank">查看全部评论</a></td>  </tr>  </form></table>');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -