SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Poole, UK
    103 Post(s)
    0 Thread(s)

    Question Javascript & External "Configuration" Variables

    How do I pass variables to an external JavaScript file, for a script which will do one thing if the external variable equals something and will do soemthing else if the external vaiable does not match. ie

    for clock display
    External Vaiable in main file = 12 (alternative is 24
    function in external javascript file checks) whether the external variable is equal to 12 or 24

    if equal to 12 javascript file displays time in 12hr time format
    if equal to 24 javascript file displays time in 24hr format
    if not equal to either 12 or 24, generate an error

  2. #2
    SitePoint Evangelist vikrantkorde's Avatar
    Join Date
    Jun 2004
    Mumbai, India
    0 Post(s)
    0 Thread(s)
    Java script do not have something like extern in C.
    However in Java script you can define a global variable and assign the value.
    you can have a variable initialised in the some other file
    and you can include that file as a Java Script source in the current file.
    It will work like a variable initialised in the current file itself.
    Vikrant Korde
    S Y S T I M E, Mhape,
    Mumbai, Maharashtra, India.


Posting Permissions

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