开发者

how to replace € into € with javascript?

开发者 https://www.devze.com 2023-03-15 08:27 出处:网络
i\'m trying to fix this forum where html entities are not displayed correctly. since the o开发者_C百科wner is m.i.a. i\'m trying to do this with an extension.

i'm trying to fix this forum where html entities are not displayed correctly. since the o开发者_C百科wner is m.i.a. i'm trying to do this with an extension.

what i see on my screen:

euro:€
pound:£ 

view of the html DOM with firebug

how to replace € into € with javascript?

my code:

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

which returns:

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

so my code seems to be working until the point it has to replace.

are those rectangles preventing it? did i do something wrong?

and if so how can i fix this?

thanks.


You forgot to assign the result of replace:

text = text.replace(...);
0

精彩评论

暂无评论...
验证码 换一张
取 消