问题
I dont know why on earth jquery html() is doing this, but after i do
$('html').html()
i get "©" automatically converted to ©
anyway to avoid this? I need to dump the html of the page using javascript and dont need this useless conversions that are screwing up the html.
回答1:
This really isn't the jQuery, or even JavaScript for that matter.
The browser will hold its own normalised representation of the underlying DOM. It will bear a close resemblence the the document itself, but character decoding (like the above) will be preserved.
Have a read of the following:
http://www.brainjar.com/dhtml/intro/
http://bytes.com/topic/javascript/answers/146257-body-innerhtml-issue
I'm afraid there is no way around this as far as I am aware.
回答2:
jQuery should not. check what you really get using in FF firebug.
console.log($('html').html());
来源:https://stackoverflow.com/questions/4283434/jquery-html-is-decoding-html-entities-by-default