易截截图软件、单文件、免安装、纯绿色、仅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, '"');


相关文档:

[翻译]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(024)

Data Format Conclusions  数据格式总结
    Favor lightweight formats in general; the best are JSON and a character-delimited custom format. If the data set is large and parse time becomes an issue, use one of these two techniques:
    总的来说越轻量级的格式越好,� ......

[翻译]High Performance JavaScript(028)

JavaScript Minification  JavaScript紧凑
    JavaScript minification is the process by which a JavaScript file is stripped of everything that does not contribute to its execution. This includes comments and unnecessary whitespace. The process typically reduces the file size by ha ......

[翻译]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 对象进行编程很简单,一般要经过如下的步骤: 创建FileSystemObject对象、应用相关方法、� ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号