JackVimal
JackVimal

Reputation: 355

cannot create object in IE using new Keyword

var com = {};
var com.Project = function(){
   this.display = function(){
   alert("hai.....");
   }
}
var project_obj = new com.Project();

while creating the project_obj i got an error in IE9 like "Object doesn't support this action"

this code working well in firefox and chrome. i have given a sample code. i'm trying to use Classes and package concept in javastript.

i don't know why this error came in IE.

Upvotes: 2

Views: 947

Answers (3)

HMR
HMR

Reputation: 39270

Based on the working link to your javascript code I think you should change this

$.extend(true, window, container[0]);

to

$.extend(true, window, d);

Upvotes: 0

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123473

The problem is the 1st line, as variable names cannot include ..

If you're trying to namespace, you need to first define com as an Object with Project as one of its properties:

var com = {
    Project: function () {
        // etc.
    }
};

Upvotes: 2

Denys Séguret
Denys Séguret

Reputation: 382150

This is illegal in all browsers and raises a syntax error :

var com.Project = function(){

You may do this :

var com = {}; // whatever
com.Project = function(){

Upvotes: 2

Related Questions