如何更换€用javascript加入€?

时间:2011-06-24 11:53:44

标签: javascript html

我正在尝试修复此论坛,其中html实体未正确显示。 因为主人是m.i.a.我试图通过扩展来做到这一点。

我在屏幕上看到的内容:

euro:€
pound:£ 

使用firebug查看html DOM

bit of html-dom as seen with firebug

我的代码:

GM_log('before text= '+text); 
text.replace( /amp;/gi, function( $0 ) {
    GM_log('$0= '+$0);
    fix="";
    return fix; 
});
GM_log(' after text= '+text); 

返回:

 before text= euro: &amp;#8364; <br>pound: &amp;#163;
 $0= amp;
 $0= amp;
 after text= euro: &amp;#8364; <br>pound: &amp;#163;

所以我的代码似乎正在工作,直到它必须替换。

那些阻止它的矩形?我做错了什么?

如果有,我该如何解决这个问题?

感谢。

1 个答案:

答案 0 :(得分:2)

您忘记分配replace的结果:

text = text.replace(...);