문제

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

도움이 되었습니까?

해결책

script.charset="GBK";//or other charset
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top