易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript String.replace函数

    javascript的String类内置函数replace(regexp, newString)函数提供了字符串替换功能,从函数原型上可以看出支持 Regular Exp。此函数功能非常实用,但也有几个地方有点混淆,下面通过实际的例子来说明:
    比如我们现在要针对串
var src="<a href=&quot;http://xx.com/a/20100601/000224.htm&quot; target=&quot;_blank&quot;>xxx</a>"
要替换其中的HTML双引号的转移符 &quot; 为实际的 " , 正常我们就会直接调用 src.replace(/&quot;/g, '"');来达到目的,但是js容易让人迷惑的一点就是,这样做并没有实际改变src的值,实际测试发现返回值才是我们需要的结果,而src本身确不发生变化,所以实际中需要通过如下来完成我们的功能:
     src=src.replace(/&quot;/g, '"');


相关文档:

通过javascript获得url参数

页面提交数据一般有两种方法:get,post。post就是所谓的form提交,使用视图;get是通过url提交。
Get方法一般用后台代码(如asp,asp.net)获得参数,代码很简单:Request.QueryString["id"];即可获取。 
有些时候需要直接在前台获取url参数,要用到javascript,js没有直接获取url参数的方法,那么,我们如何通过js ......

[翻译]High Performance JavaScript(023)

Data Formats  数据格式
    When considering data transmission techniques, you must take into account several factors: feature set, compatibility, performance, and direction (to or from the server). When considering data formats, the only scale you need for comparison is speed.
......

[翻译]High Performance JavaScript(026)

Use the Fast Parts  使用速度快的部分
    Even though JavaScript is often blamed for being slow, there are parts of the language that are incredibly fast. This should come as no surprise, since JavaScript engines are built in lower-level languages and are therefore compiled. Thou ......

javascript prototype介绍的文章

JavaScript是基于对象的,任何元素都可以看成对象。然而,类型和对象是不同的。本文中,我们除了讨论类型和对象的一些特点之外,更重要的是研究如何写出好的并且利于重用的类型。毕竟,JavaScript这种流行的脚本语言如果能够进行良好的封装,并形成一个庞大的类型库,对于重用是非常有意义的。
网上对于prototype的文章很 ......

JavaScript 读取 JSON


JSON:
[{"subjecttypeId":"1","subjectName":"67","scope":"1",},{"subjecttypeId":"1","subjectName":"345","scope":"1"}]
JavaScript:
       var result = window.eval('(' + JSON+ ')');

for(var p in result){

result[p].subjectName;

alert(result[p] ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号