I have 2 methods, one is internal method and the other one is instance method,
When I'm calling my internal function(onkeydown="javascript:return checkChatBoxInputKey();") it works great,
But when I'm trying to activate the onclick event (onclick="this.CloseChatBox();) I get the following error:
0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'CloseChatBox'
Here is my code:
function ChatBox(){
// Methods
this.CloseChatBox = ChatBox.CloseChatBox;
// Adding new chat box to page
$(" <div />").attr("id", "chatbox")
.html('<div class="chatboxhead">' +
'<a href="javascript:void(0)" title="Close chat box" onclick="this.CloseChatBox();">X</a>' + // This line fails to work
'</div>' +
'<div class="chatboxbody">' +
'<textarea onkeydown="javascript:return checkChatBoxInputKey();"></textarea>' +
'</div>')
.appendTo($("body"));
$("#chatbox_" + this.CallId).show();
return true;}
function checkChatBoxInputKey(){
alert("checkChatBoxInputKey");}
ChatBox.CloseChatBox = function (){
alert("CloseChatBox");}
What can I do?
$(" <div />").attr("id", "chatbox"), make sure that you don't have multiple elements with the same ID.