Click here to Skip to main content
16,010,392 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: How to change the speed of the scrollbar of a div? Pin
Shog927-Nov-06 4:58
sitebuilderShog927-Nov-06 4:58 
QuestionUnable to use prototype with my javascript custom object. Pin
howardjr22-Nov-06 9:20
howardjr22-Nov-06 9:20 
AnswerRe: Unable to use prototype with my javascript custom object. Pin
howardjr22-Nov-06 10:09
howardjr22-Nov-06 10:09 
GeneralRe: Unable to use prototype with my javascript custom object. Pin
led mike22-Nov-06 10:28
led mike22-Nov-06 10:28 
GeneralRe: Unable to use prototype with my javascript custom object. Pin
howardjr24-Nov-06 1:18
howardjr24-Nov-06 1:18 
GeneralRe: Unable to use prototype with my javascript custom object. Pin
led mike27-Nov-06 5:19
led mike27-Nov-06 5:19 
GeneralRe: Unable to use prototype with my javascript custom object. Pin
howardjr28-Nov-06 6:35
howardjr28-Nov-06 6:35 
AnswerRe: Unable to use prototype with my javascript custom object. Pin
Shog922-Nov-06 15:05
sitebuilderShog922-Nov-06 15:05 
howardjr wrote:
The books I have on Javascript don't indicate that IE6 doesn't support this feature, but from the error I'm getting ('this.prototype' is null or not an object) the magic where the prototype sub-object of my NameObject is supposed to be automatically created and then the members exposed in my class isn't happening.

It is. You're misunderstanding how it works and how it can be used.

Every object in JavaScript has a prototype. It's how JS object inheritance works. However, you can't change the prototype for an object; you can only specify what the prototype will be for new objects. By the time your NameObject constructor executes, it's too late - the new object has already been created, all you can do is initialize it. Even if you created a new object and assigned it to this.prototype, it wouldn't do any good - the .prototype member only tells the interpreter what it should use as the prototype for new objects created based on the object.

What you really want to do is set up the prototype before creating new NameObject objects:
function NameObject( Name )
{
   this.Name = Name;
   this.FixName();
}
NameObject.prototype.FixName = function()
{
   if ( this.Name && this.Name.length != 0 )
      this.Name = this.Name.charAt(0).toUpperCase() + (this.Name.length > 1 ? this.Name.slice(1) : '');
}


var Ted = new NameObject( 'ted' );
var Bill = new NameObject( 'bill' );




GeneralRe: Unable to use prototype with my javascript custom object. Pin
howardjr24-Nov-06 1:33
howardjr24-Nov-06 1:33 
QuestionIE not rendering consistantly with Opera and FF Pin
JimmyRopes22-Nov-06 4:28
professionalJimmyRopes22-Nov-06 4:28 
AnswerRe: IE not rendering consistantly with Opera and FF Pin
Guffa22-Nov-06 13:35
Guffa22-Nov-06 13:35 
GeneralRe: IE not rendering consistantly with Opera and FF Pin
JimmyRopes22-Nov-06 16:02
professionalJimmyRopes22-Nov-06 16:02 
GeneralRe: IE not rendering consistantly with Opera and FF Pin
Guffa22-Nov-06 18:52
Guffa22-Nov-06 18:52 
GeneralRe: IE not rendering consistantly with Opera and FF Pin
JimmyRopes22-Nov-06 19:39
professionalJimmyRopes22-Nov-06 19:39 
AnswerRe: IE not rendering consistantly with Opera and FF Pin
Guffa22-Nov-06 21:30
Guffa22-Nov-06 21:30 
GeneralRe: IE not rendering consistantly with Opera and FF Pin
JimmyRopes23-Nov-06 5:13
professionalJimmyRopes23-Nov-06 5:13 
AnswerRe: IE not rendering consistantly with Opera and FF Pin
Guffa23-Nov-06 7:36
Guffa23-Nov-06 7:36 
AnswerRe: IE not rendering consistantly with Opera and FF Pin
Johnny ²22-Nov-06 14:00
Johnny ²22-Nov-06 14:00 
GeneralRe: IE not rendering consistantly with Opera and FF Pin
JimmyRopes22-Nov-06 14:31
professionalJimmyRopes22-Nov-06 14:31 
Questionjavascript 'new RegExp()' notation Pin
pint_of_best22-Nov-06 0:31
pint_of_best22-Nov-06 0:31 
AnswerRe: javascript 'new RegExp()' notation Pin
Guffa22-Nov-06 5:46
Guffa22-Nov-06 5:46 
QuestionIE Extension Pin
Richard Andrew x6421-Nov-06 3:02
professionalRichard Andrew x6421-Nov-06 3:02 
AnswerRe: IE Extension Pin
Bradml21-Nov-06 22:16
Bradml21-Nov-06 22:16 
QuestionScript question.... Pin
KORCARI20-Nov-06 21:44
KORCARI20-Nov-06 21:44 
AnswerRe: Script question.... Pin
howardjr24-Nov-06 15:27
howardjr24-Nov-06 15:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.