SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cross-Browser JavaScript Constants

    I found this just now:

    http://webreflection.blogspot.com/20...-function.html

    And it seems to work!

    The only problem is that if you re-define the define function (define = null) then you cannot create anymore constants.

    BUT YOU CANNOT REDEFINE THE CONSTANTS


    --- EDIT ---

    My apologies. It works fine with Firefox, but Opera doesn't seem to do anything about it. IE(6|7) the javascript variable to be re-defined but only with MYVAR = 5.

    I don't think that there is a workaround to this because the javascript variables can always be re-defined with IE.
    I can't believe I ate the whole thing

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,717
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    There are ways of creating constants in javascript.
    Douglas Crockford has an article about Top Down Operator Precedence which as a part of it delves into the constants issue.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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