下载首页下载分类最近更新排 行 榜国产软件国外软件汉化补丁本站论坛BT下载页
  • 设为首页
  • 收藏本站
  • 联系我们
您的位置:首页网页制作JS/Ajax → js技巧收集(200多个)
js技巧收集(200多个)
出处:本站整理 作者:佚名 日期:2007-5-7 17:09:38 人气: [ ]

document.

Property/    Method Description
XMLDocument Returns a reference to the XML Document Object Model (DOM) exposed by the object. 

documentElement  Returns the document root of the XML document.
childNodes    Returns a node list containing the children of a node (if any).
item     Accesses individual nodes within the list through an index. Index values are zero-based, so

item(0) returns the first child node.
text     Returns the text content of the node.

The following code shows an HTML page containing an XML data island. The data island is contained within

the <XML> element.

<HTML>
  <HEAD>
    <TITLE>HTML with XML Data Island</TITLE>
  </HEAD>
  <BODY>
    <P>Within this document is an XML data island.</P>

    <XML ID="resortXML">
      <resorts>
        <resort code='1'>Adventure Works</resort>
        <resort>Alpine Ski House</resort>
      </resorts>
    </XML>

  </BODY>
</HTML>
For an example, you can cut and paste this sample line of code:

resortXML.XMLDocument.documentElement.childNodes.item(1).text//读取页面上的XML数据岛中的数据
resortXML.documentElement.childNodes.item(0).getAttribute("code")//读取页面上的XML数据岛中的数据
resortXML.documentElement.childNodes[0].getAttribute("code")//读取页面上的XML数据岛中的数据

199.模式窗口
父窗口
var url="aaa.jsp";
var

data=showModalDialog(url,null,"dialogHeight:400px;dialogHeight:600px;center:yes;help:No;status:no;resizab

le:Yes;edge:sunken");
if(data)
 alert(data.value);
 
子窗口
var data=new Object();
data.value1="china";
window.returnValue=data;
window.close();


200.动态设置事件,带参数
<INPUT TYPE="text" NAME="a1">
<SCRIPT LANGUAGE="JavaScript">
<!--
function hah(para)
{
 alert(para)
}
a1.onclick=function()
{
 hah('canshu ')
}
//a1.attachEvent("onclick",function(){hah('参数')});
//-->
</SCRIPT>//


201.将url转化为16进制形式
 var ret = '';

 for(var i=0; i < str.length; i++)
 {
  var ch = str.charAt(i);
  var code = str.charCodeAt(i);

  if(code < 128 && ch != '[' && ch != '\'' && ch != '=')
  {
   ret += ch;
  }
  else
  {
   ret += "[" + code.toString(16) + "]";
  }
 }
 return ret;//
 

202.打开新的窗口并将新打开的窗口设置为活动窗口
var newWin=window.open("xxxx");
newWin.focus();//

相关文章
相关软件
评论人 评论内容摘要(共 0 条,查看完整内容) 得分 0 发表时间
关于本站 | 广告服务 | 版权声明 | 联系我们 | | 联系我 | 交流群:1361692 7710545
本站部分带宽由:华夏名网武汉IDC数据中心 赞助[排名不分先后] Powered By 零度软件园
本站软件均来源于网络,仅供学习所用。若侵犯了你的权益,请立即通知我们,我们将第一时间删除!