Reputation: 8626
This is JSFiddle :
I have button as follows:
<button class="buttoncss" title="Modify This Artifact File" onclick="setFileDescriptionForUpdate('!@#$%^&*()_+-=~`{}|[]\:" ;'<>?,.="" ','state.dat','167','1','c:\\pp_artifactsuploadedfiles\evalid_318\state.dat');">Modify</button>
in this on click i am calling setFileDescriptionForUpdate
function whose first parameter is string and is as follows:
!@#$%^&*()_+-=~`{}|[]\:";'<>?,./
when " is involved in string it creates problem.
What changes i can make to avoid this??
Please help me.
Upvotes: 0
Views: 643
Reputation: 958
Use below Code :-
var user = "Hi \" User";
var test = user.replace("\"", "");
document.body.innerHTML = test;
Upvotes: 1
Reputation: 2837
HTML escaping is required if going inline.
If you have to use inline javascript in html then you have to escape it
& becomes &
< becomes <
> becomes >
In attribute values you must also escape the quote character [spec]:
" becomes "
' becomes '
Upvotes: 2