强烈鄙视"既拒绝男生,又仍然和他做好朋友" >>
<< 修改了网站页面的底部导航条
replace(reg, function) in JavaScript

Author Zhou Renjian Create@ 2005-01-23 07:11
whizz Note icon

Compare the following two lines of JavaScript code:

1.  tmpStr.replace(/\?ith=([^&]*)/ig, function($0, $1) { ith = $1; return ""; });

2.  tmpStr.replace(/\?ith=([^&]*)/ig, function($0, $1) { ith = $1; });

The second one runs OK under IE6 and Mozilla, but it will throws an error under Opera 7. And the first one will runs well on all these 3 browsers 'cause there is  a correct "return" line in the function argument. That is the key line!

本记录所在类别:
本记录相关记录: