javascript - Uncaught TypeError: Cannot call method 'replace' of undefined -
var container = document.getelementbyid("f2"); text = text.replace(/\:\)/g, '<img src="images.jpg" border="0">'); in code getting error.
in starting of function text defined var. f2 code here:
<table style='width: 100%'> <tr> <td> <textarea id="fname" class="span5 chattextarea" style="resize: none;" cols="240" rows="13" disabled="disabled" style="float:centre" style="background-color: transparent" style="border: 3px dotted #f7730e;"></textarea> </td> </tr> <tr> <td> <input type="text" id="f2" style="width: 440; height:100%" class="chattextarea" autocomplete="off" onkeyup="javascript: if (event.keycode==13) testchat();" placeholder= "type message"></input> <input type="button" class="btn-success" style="width: 50px" value="send" onclick="testchat()"></input> </td> </tr> </table> uncaught typeerror: cannot call method 'replace' of undefined
you haven't defined variable text anywhere.
change text.replace() container.innerhtml.replace()
and suspect want doing afterwards
container.innerhtml = text; so container element gets image it's new content.
Comments
Post a Comment