javascript²Ù×÷XmlÔöɾ¸Ä²é(IEÏÂ)
HTMLÎļþ£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>js²Ù×÷XmlÔöɾ¸Ä²é(IEÏÂ)</title>
<script type="text/javascript"><!--
/*µÈ½â¾öµÄÎÊÌâ:
1.xpathµ½µ×ÊǶ¨Î»µ½ÄÄÒ»²ã,ÔõÑù¶¨Î»µ½±ÈÈçrootÕâÒ»¼¶»¹ÊÇperson»ònameÕâÒ»¼¶.
*/
var xmlDoc;
var rootNode; //¸ù½áµã
//×°ÔØXmlÎĵµ
function loadXml(){
try{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;//¹Ø±ÕÒì²½¼ÓÔØ
xmlDoc.load("XmlFile.xml");//loadÊÇ´ÓÎļþ,loadXMLÊÇ´Ó×Ö·û´®.
rootNode = xmlDoc.documentElement;
}catch(e) {alert(e.message)}
}
//ÏÔʾÄÚ´æÖеÄXmlÎĵµ
function outXml(){
var divXml=document.getElementById("divXml");
divXml.innerHTML=xmlDoc.xml;//ÏÔʾxmlÄÚÈÝ,¼¼ÇÉÊǼӸöxmlºó׺.?
alert(xmlDoc.xml);
}
//Ôö
function addXml(){
//Ò¶×Ó½áµã,ÉèÖÃtextÖµ
var newName = xmlDoc.createElement("name");
newName.text = "crane";
var newGender = xmlDoc.createElement("gender");
newGender.text = "female";
//¸¸¼¶½áµã,ÓÃappendChild(childNode);
var newPerson = xmlDoc.createElement("person");
//ÉèÖÃÊôÐÔid
newPerson.setAttribute("id","2");
newPerson.appendChild(newName);
newPerson.appendChild(newGender);
//Ôö¼Óµ½¸ù½áµã
rootNode.appendChild(newPerson);
alert(xmlDoc.xml);
}
//ɾ
function deleteXml(){
//ÏÈÕÒµ½½áµã
var singleNode = xmlDoc.selectSingleNode("/root/person[name='tree']");
//ÕÒµ½¸¸¼¶ÔÙɾ³ý
singleNode.parentNode.removeChild(singleNode);
alert(xmlDoc.xml)
Ïà¹ØÎĵµ£º
ÐÂÖÐ……
1¡¢Êý¾ÝÀàÐÍÑéÖ¤ÎÊÌâ
Asp.NetËäÈ»ÓÐÑéÖ¤¿Ø¼þ£¬µ«ÊÇÓÐЩ¸´ÔÓµÄÑéÖ¤»¹Êǵô«µ½·þÎñÆ÷ÉϽøÐУ¬ÓÃjsËٶȺÍÐÔÄܶ¼±È½ÏºÃ
<script>
//¼ì²éÊÇ·ñΪÈÎÒâÊý£¨ÊµÊý£©
function isNumeric(strNumber) {
var newPar=/^(-|\+)?\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
//¼ ......
javascriptµÄStringÀàÄÚÖú¯Êýreplace(regexp, newString)º¯ÊýÌṩÁË×Ö·û´®Ìæ»»¹¦ÄÜ£¬´Óº¯ÊýÔÐÍÉÏ¿ÉÒÔ¿´³öÖ§³Ö Regular Exp¡£´Ëº¯Êý¹¦Äܷdz£ÊµÓ㬵«Ò²Óм¸¸öµØ·½Óеã»ìÏý£¬ÏÂÃæͨ¹ýʵ¼ÊµÄÀý×ÓÀ´ËµÃ÷£º
±ÈÈçÎÒÃÇÏÖÔÚÒªÕë¶Ô´®
var src="<a href="http://xx.com/a/2010 ......
ÔÚjavascriptÖеÄstring¶ÔÏóûÓÐtrim·½·¨£¬ËùÒÔtrim¹¦ÄÜÐèÒª×Ô¼ºÊµÏÖ£º
´úÂëÈçÏ£º
Java´úÂë
﹤scriptlanguage=”javascript”﹥
/**
*ɾ³ý×óÓÒÁ½¶ËµÄ¿Õ¸ñ
*/
String.prototype.trim=function(){
&nbs ......
ʹÓùýajaxµÄ¶¼³£¼ûÕâÑùµÄ´úÂ룺
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
µ«Õâ¶ùµÄvoid(0)¾¿¾¹ÊǺκ¬ÒåÄØ£¿
JavascriptÖÐvoidÊÇÒ»¸ö²Ù×÷·û£¬¸Ã²Ù×÷·ûÖ¸¶¨Òª¼ÆËãÒ»¸ö±í´ïʽµ«ÊDz»·µ»ØÖµ¡£
void ²Ù×÷·ûÓ÷¨¸ñʽÈçÏ£º
1. jav ......
1. document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËصÄID號 ").name(»òvalue)
6.Ò ......