Frage

I am doing a chrome extension which may append a button to any web pages using chrome extension, contentscript. The problem is the charset of the web pages are uncertain, which means that I may append my node to the web pages with different charset. Sometimes it may come with messy code.

Here's the example:

content_script.js:

(function(){
    var script = document.createElement('script')
    script.setAttribute('src', 'url_to_my_javascript')
    document.body.appendChild(script)
})()

my_javascript.js:

$('body').append('<button>确定(chinese,means ok)</button>')

That comes with messy code on some pages with 'gbk' charset

War es hilfreich?

Lösung

script.charset="GBK";//or other charset
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top