VectorLinux
September 23, 2014, 03:59:16 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: What's the effect of newline in javascript?  (Read 2938 times)
roarde
Vectorian
****
Posts: 530


move the needle


« on: March 30, 2010, 02:41:49 am »

I lost a neat widget provided by my isp after they did a page edit. Turns out the tool they used reformatted the text and added a newline in the middle of the widget's window open definition. "Javascript" is defined:
Code:
<script type="text/javascript">

The error(?) is here:
Code:
function opensessionwin(whichone) {
remote =
window.open("","sessionwin","width=240,height=400,toolbar=0,location=0,directories=0,status=0,menubar=0[EXTRA NEWLINE HERE]
,scrollbars=1,resizable=1");

Question is, is newline in code supposed to be ignored as in html, or is it interpreted as, say, bash would? (BTW, "{" is matched by "}" at end of declaration.)

Not interested in writing js myself, but don't want to send in an erroneous fix request.

thank you
Logged

Robert
VL STD 7.1 RC2.2.2, icewmvmods
retired1af
Packager
Vectorian
****
Posts: 1262



« Reply #1 on: March 30, 2010, 05:30:10 am »

Just whipped this off to a friend who does java  programming for a living. Should hear back shortly.  Grin
Logged

ASUS K73 Intel i3 Dual Core 2.3GHz
retired1af
Packager
Vectorian
****
Posts: 1262



« Reply #2 on: March 30, 2010, 06:02:47 am »

Buddy says it looks like it's a "reminder" for additional code to be added later. The brackets would break the app and prevent it from running properly. Smiley
Logged

ASUS K73 Intel i3 Dual Core 2.3GHz
roarde
Vectorian
****
Posts: 530


move the needle


« Reply #3 on: March 31, 2010, 01:05:11 pm »

Thanks, retired1af. They may indeed have wished to disable it. It gives session length, remaining, etc., and sometimes conficts with the figures given by their support personnel.

Does leave me wondering how js knows the beginning and end of a declaration, tho.
Logged

Robert
VL STD 7.1 RC2.2.2, icewmvmods
roarde
Vectorian
****
Posts: 530


move the needle


« Reply #4 on: March 31, 2010, 01:06:45 pm »

Just re-read. Your java-programming buddy knew it's javascript, right?
Logged

Robert
VL STD 7.1 RC2.2.2, icewmvmods
retired1af
Packager
Vectorian
****
Posts: 1262



« Reply #5 on: March 31, 2010, 01:20:26 pm »

Yepper.
Logged

ASUS K73 Intel i3 Dual Core 2.3GHz
roarde
Vectorian
****
Posts: 530


move the needle


« Reply #6 on: April 02, 2010, 01:28:48 am »

I'll have to try for clarity one more time.

[EXTRA NEWLINE HERE] (including "[" and "]") was inserted by me in hopes of better pointing out the "extra" newline. "[]" being notation for "inserted by editor", I used it. Seems I'm speaking English when I should be speaking code.

So, was it "{}" (the original) or "[]" (my insertion) that broke the code.

I'd still like to know what newline (or may be win CRLF) does in js code.

Thanks again.
Logged

Robert
VL STD 7.1 RC2.2.2, icewmvmods
retired1af
Packager
Vectorian
****
Posts: 1262



« Reply #7 on: April 02, 2010, 02:10:06 am »

Square brackets are used to reference objects. Even with my limited abilities in writing code, what is between those brackets (INSERT NEWLINE HERE) is not an object. To insert a new line in javascript, \n is used.

If the author is attempting to insert a comment, using square  brackets isn't the way to go as they definitely have a use within javascript, and adding comments isn't one of those uses.
Logged

ASUS K73 Intel i3 Dual Core 2.3GHz
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!