jeesrinu
asked on
Spcialchars in javascript similar like php
Hi,
When i run this below code it is not woking Properly
I want to expect the output as
<?php function zz(& $x) { $x=$x+5; }?>
How can display in javascript by using document.write method .Please help me
Thanks in advance
When i run this below code it is not woking Properly
I want to expect the output as
<?php function zz(& $x) { $x=$x+5; }?>
How can display in javascript by using document.write method .Please help me
Thanks in advance
<?
echo "test";
?>
<script>
function htmlspecialchars(str) {
if (typeof(str) == "string") {
alert((str));
str = str.replace(/&/g, "&"); /* must do & first */
str = str.replace(/"/g, """);
str = str.replace(/'/g, "'");
str = str.replace(/</g, "<");
str = str.replace(/>/g, ">");
}
return str;
}
document.write(htmlspecialchars('<? htmlspecialchars('<?php function zz(& $x) { $x=$x+5; }?>')?>'));
</script>
ASKER
Hi seetharaml,
I am not getting Proper solution from this link . I have already used the regular expressions. In my coding please see the 7 th line alert(str) can displayed the blank alert box. Have any ideas please help me
I am not getting Proper solution from this link . I have already used the regular expressions. In my coding please see the 7 th line alert(str) can displayed the blank alert box. Have any ideas please help me
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you check the following url and let me know,
https://www.experts-exchange.com/questions/20999435/Blocking-Special-Characters.html
Thanks