开发者

How to write this javascript without using apostrophes

开发者 https://www.devze.com 2023-04-06 10:20 出处:网络
I\'m trying to get a line of flags wiht google translate on my site. This other site already has it, but it uses blogger API. I changed the JS accordingly, but I found out that my forum software encod

I'm trying to get a line of flags wiht google translate on my site. This other site already has it, but it uses blogger API. I changed the JS accordingly, but I found out that my forum software encodes de apostrophe as \'

Is there any way I can write the same html+js below without using apostrophes?

<a  target="_blank" rel="nofollow"  
onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(document.URL)+'&langpair=pt%7Czh-CN&hl=pt&ie=UTF8'); return false;"
title="Google-Translate-Chinese (Simplified) BETA"><img  style="border: 0px solid ; cursor: pointer; width: 24px; height: 24px;"
alt="Google-Transl开发者_高级运维ate-Chinese" src="http://lh5.ggpht.com/_mcq01yDJ2uY/Sdke4C8za2I/AAAAAAAAAkU/Mpfn_ntCweU/China.png"
title="Google-Translate-Chinese">

As it is, the forum engine translates it as ""window.open(\'http://www.google.com/translate?u=\'+"


Try using something like this

onclick="window.open(\"http://www.google.com/translate?u=\"+encodeURIComponent
(document.URL)+\"&langpair=pt%7Czh-CN&hl=pt&ie=UTF8\"); return false;"

Since you are already using escape string, your forum engine might not replace this with another '\'.

0

精彩评论

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

关注公众号