Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

here is my code... got error..please help me to sort this out...

HTML
<html>
<head></head>
<body>
<script type="text/javascript">

var objct1= new objct();
objct1.checkIfActive();    // Error.......... Object doesn't support this property or method......

var objct2= new objct(true);
objct2.checkIfActive();

	function objct(isUnderCover)
	{
	 	if(isUnderCover)
		this.isSecret=true;
			
	}
	
	objct.prototype.isSecret=false;
	objct.prototype.isActive=true;
	objct.prototype.checkIfActive=function()
		{
		 if(this.isActive)

		    alert("This Object is Active...is this secret..?"+this.isSecret)

		 else

		   alert("This Object is Not Active...is this secret..?"+this.isSecret)	
		};

</script>
</body>
</html>
Posted
Updated 25-Mar-13 21:26pm
v2
Comments
Monster Maker 26-Mar-13 3:24am    
I ran your script in chrome,

it ran perfectly..
AVINCODE 26-Mar-13 3:49am    
Hi but its neither run in IE8 nor in Firefox....its giving same error..Can you plz check this with IE and Firefox...?
Monster Maker 26-Mar-13 4:06am    
friend, it works fine in my IE7
AVINCODE 26-Mar-13 5:12am    
Thanks.....
Prasad Khandekar 26-Mar-13 4:54am    
Hello Try moving the object declaration ahead of the statement where it is used. e.g
<html>
<head></head>
<body>
<script type="text/javascript">
function objct(isUnderCover)
{
if (isUnderCover)
this.isSecret = true;
}

objct.prototype.isSecret = false;
objct.prototype.isActive = true;
objct.prototype.checkIfActive = function()
{
if(this.isActive)
alert("This Object is Active...is this secret..?"+this.isSecret)
else
alert("This Object is Not Active...is this secret..?"+this.isSecret)
};

var objct1= new objct();
objct1.checkIfActive(); // Error.......... Object doesn't support this property or method......

var objct2= new objct(true);
objct2.checkIfActive();

</script>
</body>
</html>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900