line break character in javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    line break character in javascript

    What is the syntax for line break character in javascript?? For example, the
    following code will yield error "
    unterminated string constant." If I put the following in one line, then no
    error.

    window.showModa lDialog("page2. html",
    document,"menub ar=no, titlebar=no, toolbar=no, location=no,
    directories=no, status=no, menubar=no,scro llbars=yes, resizable=no,
    copyhistory=yes , width=400, height=500");


    Please advise. thanks!!
  • Michael Winter

    #2
    Re: line break character in javascript

    On 6 Mar 2004 08:08:13 -0800, Matt <jrefactors@hot mail.com> wrote:
    [color=blue]
    > What is the syntax for line break character in javascript?? For example,
    > the following code will yield error "unterminat ed string constant."
    > If I put the following in one line, then no error.
    >
    > window.showModa lDialog("page2. html",
    > document,"menub ar=no, titlebar=no, toolbar=no, location=no,
    > directories=no, status=no, menubar=no,scro llbars=yes, resizable=no,
    > copyhistory=yes , width=400, height=500");[/color]

    Placing a line break in that string might cause problems anyway. What
    you're looking for is a way to concatenate strings so you can spread them
    across multiple lines. Use:

    myFunction( 'first part of a string' +
    'second part of a string' );

    That would be the same as passing

    'first part of a stringsecond part of a string'

    to the function (no space between 'string' and 'second' is intentional).

    However, you can actually shorten that string; boolean values can be
    omitted if false. It is their default value. You could write:

    window.showModa lDialog('page2. html', document,
    'scrollbars,cop yhistory,resiza ble,width=400,h eight=500');

    Note that you can also omit '=yes', and that I removed the spaces. The
    former isn't necessary, and the latter isn't allowed. Finally, notice that
    I included resizable: you shouldn't prevent the user from resizing the
    page - it is their browser, not yours.

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

    Comment

    Working...