Click here to Skip to main content
15,896,726 members
Home / Discussions / JavaScript
   

JavaScript

 
SuggestionRe: a little help for DragandDrop data transfer Pin
Dennis E White24-May-13 16:54
professionalDennis E White24-May-13 16:54 
QuestionHelp for below java script Pin
abmanish7123-May-13 17:22
abmanish7123-May-13 17:22 
QuestionRe: Help for below java script Pin
ZurdoDev24-May-13 4:27
professionalZurdoDev24-May-13 4:27 
QuestionJavascript/jquery problem Pin
#realJSOP22-May-13 9:46
professional#realJSOP22-May-13 9:46 
AnswerRe: Javascript/jquery problem Pin
Dennis E White22-May-13 10:31
professionalDennis E White22-May-13 10:31 
GeneralRe: Javascript/jquery problem Pin
#realJSOP23-May-13 0:54
professional#realJSOP23-May-13 0:54 
GeneralRe: Javascript/jquery problem Pin
Dennis E White23-May-13 4:09
professionalDennis E White23-May-13 4:09 
GeneralRe: Javascript/jquery problem Pin
#realJSOP24-May-13 2:54
professional#realJSOP24-May-13 2:54 
I was trying to do this:

JavaScript
function MyClass
{
    this.property1 = 'somevalue1';
    this.property2 = 'somevalue2';

    this.Height = 0;
    this.Width = 0;

    $('<img />').attr({'id': id, 'src' : src}).load(function()
    {
        if (true === this.complete)
        {
            Width = this.width;
            Height = this.height;
        }
    });
}


That didn't work (this.width and this.height were the expected values, but trying to assign the vars did not work. So I changed it to this:

JavaScript
function MyClass
{
    this.property1 = 'somevalue1';
    this.property2 = 'somevalue2';

    var Height = 0; // <----------
    var Width = 0;  // <----------

    $('<img />').attr({'id': id, 'src' : src}).load(function()
    {
        if (true === this.complete)
        {
            Width = this.width;
            Height = this.height;
        }
    });

    // and added these functions

    this.width = function()
    {
        return Width;
    }

    this.height = function()
    {
        return Height;    
    }
}


I have no idea why I can't assign vars the way I originally tried it. IMHO, Javascript is nothing more than a hack whose main intent is to drive real programmers insane.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997


GeneralRe: Javascript/jquery problem Pin
Dennis E White24-May-13 6:08
professionalDennis E White24-May-13 6:08 
GeneralRe: Javascript/jquery problem Pin
#realJSOP25-May-13 11:18
professional#realJSOP25-May-13 11:18 
GeneralRe: Javascript/jquery problem Pin
Dennis E White25-May-13 11:27
professionalDennis E White25-May-13 11:27 
GeneralRe: Javascript/jquery problem Pin
#realJSOP26-May-13 2:49
professional#realJSOP26-May-13 2:49 
GeneralRe: Javascript/jquery problem Pin
User 171649225-May-13 11:37
professionalUser 171649225-May-13 11:37 
GeneralRe: Javascript/jquery problem Pin
#realJSOP26-May-13 3:01
professional#realJSOP26-May-13 3:01 
GeneralRe: Javascript/jquery problem Pin
User 171649226-May-13 4:47
professionalUser 171649226-May-13 4:47 
QuestionHow to Add Days in Javascript Date Object Pin
Robymon22-May-13 2:26
Robymon22-May-13 2:26 
AnswerRe: How to Add Days in Javascript Date Object Pin
Richard Deeming22-May-13 3:23
mveRichard Deeming22-May-13 3:23 
AnswerRe: How to Add Days in Javascript Date Object Pin
Dennis E White22-May-13 4:39
professionalDennis E White22-May-13 4:39 
AnswerRe: How to Add Days in Javascript Date Object Pin
Niral Soni23-May-13 1:23
Niral Soni23-May-13 1:23 
Questionfunction for split a complex string Pin
mhd.sbt21-May-13 7:06
mhd.sbt21-May-13 7:06 
AnswerRe: function for split a complex string Pin
ZurdoDev21-May-13 10:30
professionalZurdoDev21-May-13 10:30 
AnswerRe: function for split a complex string Pin
Dennis E White22-May-13 4:53
professionalDennis E White22-May-13 4:53 
AnswerRe: function for split a complex string Pin
Niral Soni23-May-13 2:36
Niral Soni23-May-13 2:36 
QuestionReading XML - success being ignored Pin
#realJSOP21-May-13 1:01
professional#realJSOP21-May-13 1:01 
AnswerRe: Reading XML - success being ignored Pin
Dennis E White21-May-13 4:49
professionalDennis E White21-May-13 4:49 

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.