We'll need to see some code. My feeling is you're missing some essential escaping step somewhere. In particular:
As soon as the string which contents "#"(basically when i try to change the color of the font) character
Implies to me that you might be sticking strings together into a URL like this:
var url= '/something.php?content='+html;
Naturally if the html
contains a #
symbol, you've got problems, because in:
http://www.example.com/something.php?content=<div style="color:#123456">
the #
begins a fragment identifier called #123456">
, like when you put #section
on the end of a URL to go to the anchor called section
in the HTML file. Fragment identifiers are purely client-side and are not sent to the server, which would see:
http://www.example.com/something.php?content=<div style="color:
However this is far from the only problem with the above. Space, <
and =
are simly invalid in URLs, and other characters like &
will also mess up parameter parsing. To encode an arbitrary string into a query parameter you must use encodeURIComponent
:
var url= '/something.php?content='+encodeURIComponent(html);
which will replace #
with %35
and similarly for the other out-of-band characters.
However if this is indeed what you're doing, you should in any case you should not be storing anything to the database in response to a GET request, nor relying on a GET to pass potentially-large content. Use a POST request instead.