Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    add property to window object

    I saw a piece of code in a javascript:

    window.dhx_globalImgPath = "test1";

    alert(window.dhx_globalImgPath );

    display: test1


    Now I try:

    window.newTest = "A New Test";

    alert(window.newTest );

    The display does not work.

    So the question is: Why is the dhx_globalImgPath so special? It must have been defined or declared somewhere. But I did a full application search for the dhx_globalImgPath. I did not find the expected definition or declaration.

    In order to make window.newTest = "A New Test"; workable, I must do something. Then what should I do?

    Thanks


    Scott

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    Your code works fine in Firefox.

    What browser are you using?

    Also, just so you know, when you declare a variable it is assigned to the window object automatically.
    Code:
    var test="hi";
    alert(test);
    alert(window.test);

    Eric
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #3
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Thanks. --Scott


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •