Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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)


Ïà¹ØÎĵµ£º

[·­Òë]High Performance JavaScript(033)

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.
    µ±ÍøÒ³»òÓ¦ÓóÌÐò±äÂýʱ£¬·ÖÎ ......

JavascriptÎļþ¼°Îļþ¼Ð²Ù×÷

JavascriptÎļþ¼°Îļþ¼Ð²Ù×÷
 
Ò»¡¢¹¦ÄÜʵÏÖºËÐÄ£ºFileSystemObject ¶ÔÏó
    ÒªÔÚjavascriptÖÐʵÏÖÎļþ²Ù×÷¹¦ÄÜ£¬Ö÷Òª¾ÍÊÇÒÀ¿¿FileSystemobject¶ÔÏó¡£
¶þ¡¢FileSystemObject±à³Ì
ʹÓÃFileSystemObject ¶ÔÏó½øÐбà³ÌºÜ¼òµ¥£¬Ò»°ãÒª¾­¹ýÈçϵIJ½Ö裺 ´´½¨FileSystemObject¶ÔÏó¡¢Ó¦ÓÃÏà¹Ø·½·¨¡¢· ......

JavaScript µ÷ÓÃ±íµ¥ÖØÖ÷½·¨


1 history.go(0)  
2 location.reload() £¨Ò³Ãæ½øÐÐˢУ¬µ«ÎªdisabledµÄÔªËØµÄÖµ²»»á±»Çå¿Õ£©
3 location=location 
4 location.assign(location) 
5 location.replace(location) 
6 from..reset()  (Ò³Ãæ²»½øÐÐˢУ¬Ä£Äâµ¥»÷¶ÔËùµ÷ÓÃ±íµ¥ÖØÖð´Å¥µÄµ¥»÷)
......

ÖÊÊý Javascript ֮ǰµÄÄǸöÓеãС벡

<mce:script type="text/javascript"><!--
document.write("<table border=1px border-color=red>"); //±í¸ñ¿ªÊ¼
for (h = 1; h <= 10; h++) {
document.write("<tr>"); //¿ªÊ¼µÚÒ»ÐÐ
for (s = 1; s <= 10; s++) {
var num = (h-1)*10+s; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ