Web Analytics Made Easy -
StatCounter Multiple Line Scripting - CodingForum

Announcement

Collapse
No announcement yet.

Multiple Line Scripting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Line Scripting

    Is there any way to put multiple lines of information(ie. return carriage usage in script does not return 'non terminated line constant' etc.) in JavaScript? Opening a new page with the coding entered into a form isn't a problem, but viewing the source code of the test page can get messy... same thing happens with HTML to be inserted to a <DIV> tag(expandable/collapsable menus).

    Any input would be appreciated.

    Guardian

  • #2
    for strings, you can do this:

    var string = "part one" +
    "part two";

    other than that, i can't think of anything. you just have to deal with it.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

    Comment


    • #3
      But in this way your script can span across multiple lines within the variable definition, correct? Even if it won't span lines on the test page?
      I actually tried the document.write method mentioned in Michael's thread, but even then it didn't insert a return carriage in the source code. Is it just that the document.write inserts the text immediately after the last write command? Speaking of which, if you were to insert a write command inside a <SCRIPT> tag by itself, where would the text default too? I tried it once but for some reason it cleared the whole page in order to write itself out, but that was probably a problem in my HTML coding, I think...

      Comment


      • #4
        wait, i thought i knew what you were asking, but now i'm not sure.

        if you declare a variable like this:

        var string = "part one" +
        "part two";

        and then document.write() it, what you'll get is "part onepart two".

        document.write inserts the text, where ever the document.write command is. if you put it in the head, it will insert the text in the head. if you put it in the middle of a sentence, it will put it wherever it appears in that sentence.

        there's another method, document.writeln(), but in HTML, it has not practical use, because HTML ignores whitespace and line breaks, compressing them. the only way to get a visible new line, using HTML, is to document.write() a <BR>
        bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

        i am a loser geek, crazy with an evil streak,
        yes i do believe there is a violent thing inside of me.

        Comment


        • #5
          I understand the scripting multiptle lines into the HTML, and how to write the tags.

          What I was asking in the original questioned, before I diverted, was if it was possible to script the source out in the same manner as you could in Notepad, actually having the source on different lines in the code itself, rather than in the visual text.

          Guardian

          Comment


          • #6
            Not if you're reading it with javascript, since javascript assumes a new line to be another statement, etc.
            Former ASP Forum Moderator - I'm back!

            If you can teach yourself how to learn, you can learn anything. ;)

            Comment


            • #7
              It seems like you are wanting something like Python's """ bla """ string constructor, which includes line breaks and everything it spans across.

              Unforunately the ECMAScript specification does not currently include anything similar.
              jasonkarldavis.com

              Comment

              Working...
              X