SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What does this line mean?

    DQM_codebase is my base but I can't figure out the rest.

    I don't understand the +? How does it know if it's a variable or not?

    document.write("<script language=\"JavaScript1.2\" src=\""+DQM_codebase+"dqm_"+brn+".js\"></script>");

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The + means it's "adding" or concatenating. It doesn't know before you run it if it's a variable. If you try and run it and the variable doesn't exist, it'll throw an error.

    Basically your code means:

    "write out <script language="Javascript1.2" src="some codebase and dqm_ and the value of brn.js"></script>"

    So, you'd need 2 variables: DQM_codebase and brn for this to function. If DQM_codebase had a value of "hello" and brn had a value of "12", then your code would be:

    <script language="javascript1.2" src="hellodqm_12.js"></script>
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just expanding a bit on how it knows whats a variable and whats not, when java prints out the line, it will simply print any text in between the quotation marks

    so if you have a variable named hello with the value "grant"

    hello = "Grant"

    it will print the hello text, see the stop of quotation marks and then go ahead and pring the variable:

    "hello " + hello

    results in

    hello Grant

    and if you want to print more plain text after, just stick another

    + " moretext" + variable + " moretext" + variable


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
  •