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)
Ïà¹ØÎĵµ£º
Summary ×ܽá
When web pages or applications begin to feel slow, analyzing assets as they come over the wire and profiling scripts while they are running allows you to focus your optimization efforts where they are needed most.
µ±ÍøÒ³»òÓ¦ÓóÌÐò±äÂýʱ£¬·ÖÎ ......
The jLayout JavaScript library provides layout algorithms for laying out components. A component is an abstraction; it can be implemented in many ways, for example as items in a HTML5 Canvas drawing or as HTML elements. The jLayout library allows you to focus on drawing the individual components i ......
±¾ÎļòÒª½éÉÜJavaScriptÖÐconfirm,alert,promptµÄÓ÷¨,Ï£Íû´ó¼Òѧϰ¹ý³ÌÖÐÄܵõ½Ò»Ð©Æô·¢¡£
window.confirm ²ÎÊý¾ÍÖ»ÓÐÒ»¸ö¡£ÏÔʾÌáʾ¿òµÄÐÅÏ¢¡£°´È·¶¨,·µ»Øtrue£»°´È¡Ïû·µ»Øfalse¡£
< SCRIPT> var bln = window.confirm("È·¶¨Âð?"); alert(bln) < /SCRIPT> window.alert²ÎÊý£¬Ö»ÓÐ ......
ʹÓùýajaxµÄ¶¼³£¼ûÕâÑùµÄ´úÂ룺
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
µ«Õâ¶ùµÄvoid(0)¾¿¾¹ÊǺκ¬ÒåÄØ£¿
JavascriptÖÐvoidÊÇÒ»¸ö²Ù×÷·û£¬¸Ã²Ù×÷·ûÖ¸¶¨Òª¼ÆËãÒ»¸ö±í´ïʽµ«ÊDz»·µ»ØÖµ¡£
void ²Ù×÷·ûÓ÷¨¸ñʽÈçÏ£º
1. jav ......
³ýÁËÓÃgetElementByTagName µÄÁíÒ»ÖÖ»ñÈ¡¶ÔÏ󼯺ϵķ½·¨
<!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>
<meta http-equiv="Content-Type" conte ......