简体   繁体   中英

How to encode javascript in blogspot?

I have a real estate blogspot website about nha dat go vap at www.nhadatsonnghia.com and I need to encode javascript code like below:

var _pEnbRH= "\x65\x76\x61\x6c\x28\x66\x75\x6e\x63\x74\x69\...x7c\x27\x29\x2c\x30\x2c\x7b\x7d\x29\x29\x0a";eval(_pEnbRH);

Does anyone know about coding please guide me, I will appreciate you a lot!

Thank you!

Can use atob and btoa which uses base64 encoding and decoding.

<script>
    var scr = "function sample() {}";
    var jsCodeToEmbed = btoa(scr);
    var oScript = document.createElement("script");
    oScript.language = "javascript";
    oScript.type = "text/javascript";
    oScript.text = atob(jsCodeToEmbed);
    document.getElementsByTagName('body').item(0).appendChild(oScript);
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM