When I wrote the front-end HTML page of the Windows application yesterday, I found a strange problem, a simple JS code, actually executed the error.
function Replacesymbol () {var val_exp = $ (' #calc_expression '). Val (); alert (val_exp); Val_exp=val_exp.replace (/(/g, ' (') Replace (/)/g, ') '). Replace (/x/g, ' * '). Replace (/÷/g, '/'); alert (val_exp); $ (' #calc_expression '). Val (val_exp);
The code is simple, that is, replacing the special characters in the expression, such as: () X÷ into the English state of the symbol, such as: () */
However, even if the above special characters are included, two alert results do not change. But the other functions in the same JS file perform normally.
Try to put this code into a separate HTML page, also perform normal.
This is obviously not a problem with this piece of code.
Then I think of it. js files are modified by the new TXT file extension, and the default is ANSI encoding. Try clicking on the menu bar in notepad++ format-to UTF-8 encoding format, save.
Execute again, OK.
Is the problem of this obscure coding format, has been tossing n long.
Later with a by VC + + to do JS friend chat about this, tell me: HTML, JS and database files, must be set to UTF-8 format, or later you have a headache!
A variety of languages and tools, desktop development and mobile development, there are all the pits, planted before you know oh.
Remember here, as a reminder!