教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> 编程基地 >> Javascript >> js技巧收集(200多个) RSS订阅
js技巧收集(200多个)
js技巧收集(200多个) (15)
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   
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();//

 
203.容错脚本
JS中遇到脚本错误时不做任何操作:window.onerror = doNothing;
指定错误句柄的语法为:window.onerror = handleError
function handleError(message, URI, line)
{// 提示用户,该页可能不能正确回应
return true; // 这将终止默认信息
}//在页面出错时进行操作

204.JS中的窗口重定向:
window.navigate("http://www.upschool.com.cn");//

205.防止链接文字折行
document.body.noWrap=true;//

206.判断字符是否匹配.
string.match(regExpression)//

207.
href="javascript:document.Form.Name.value='test';void(0);"//不能用onClick="javacript:document.Form.Name.v

alue='test';return false;"

当使用inline方式添加事件处理脚本事,有一个被包装成匿名函数的过程,也就是说
onClick="javacript:document.Form.Name.value='test';return false;"被包装成了:
functoin anonymous()
{
    document.Form.Name.value='test';return false;
}
做为A的成员函数onclick。
而href="javascript:document.Form.Name.value='test';void(0);"相当于执行全局语句,这时如果使用return语句会

报告在函数外使用return语句的错误。


208.进行页面放大
<P onmouseover="this.style.zoom='200%'" onmouseout="this.style.zoom='normal'">
sdsdsdsdsdsdsdsds
</p>//

209.放置在页面的最右边
<input type="text" value='bu2'  style="float:right">//

210.通过style来控制隔行显示不同颜色
<style>
tr{}{
bgcolor:expression(this.bgColor=((this.rowIndex)%2==0 )? 'white' : 'yellow');
}
</style>
<table id="oTable" width="100" border="1" style="border-collapse:collapse;">
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
</table>//

211.全屏最大化
newwindow=window.open("","","scrollbars")
if (document.all)
{
 newwindow.moveTo(0,0)
 newwindow.resizeTo(screen.width,screen.height)
}//

212.根据名字解析xml中的节点值
var XMLDoc=new ActiveXObject("MSXML");
XMLDoc.url="d:/abc.xml";
aRoot=XMLDoc.root;
a1.innerText=aRoot.children.item("name").text;//

 
213.在页面上解析xml的值
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/5996c682-3472-4b03-9fb0-1e08

fcccdf35.asp

来源:www.upschool.com.cn
作者:未知
关键字:JS,javascript,教程,正则,特效
发表日期:2007-2-10 12:53:00

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:预载Gif的2个JS代码(非常有用)   下一篇:


共17页 9 7 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [178 :>

2008-11-22 5:10:47
本文的相类似文章
  • js技巧收集(200多个)
  • 解密百度空间存在的JS破坏漏洞
  • 杨桃的材质教程
  • 一个HDR的小教程
  • 水晶材质教程
  • HDRI反射教程
  • 火凤凰教程详解
  • 3dsmax教程:建筑设计的材质方面的技巧谈
  • 教程实例用VRay创建冰钻石材质
  • 精品厨房的详解教程
  • 在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com