line break character in javascript

M

Matt

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.showModalDialog("page2.html",
document,"menubar=no, titlebar=no, toolbar=no, location=no,
directories=no, status=no, menubar=no,scrollbars=yes, resizable=no,
copyhistory=yes, width=400, height=500");


Please advise. thanks!!
 
M

Michael Winter

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.showModalDialog("page2.html",
document,"menubar=no, titlebar=no, toolbar=no, location=no,
directories=no, status=no, menubar=no,scrollbars=yes, resizable=no,
copyhistory=yes, width=400, height=500");

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.showModalDialog('page2.html', document,
'scrollbars,copyhistory,resizable,width=400,height=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top