VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: What's the effect of newline in javascript?  (Read 3608 times)

roarde

  • Vectorian
  • ****
  • Posts: 612
  • move the needle
What's the effect of newline in javascript?
« on: March 30, 2010, 03: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: [Select]
<script type="text/javascript">
The error(?) is here:
Code: [Select]
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 7.1 Light

retired1af

  • Administrator
  • Vectorian
  • *****
  • Posts: 1327
Re: What's the effect of newline in javascript?
« Reply #1 on: March 30, 2010, 06:30:10 am »

Just whipped this off to a friend who does java  programming for a living. Should hear back shortly.  ;D
Logged
ASUS K73 Intel i3 Dual Core 2.3GHz

retired1af

  • Administrator
  • Vectorian
  • *****
  • Posts: 1327
Re: What's the effect of newline in javascript?
« Reply #2 on: March 30, 2010, 07: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. :)
Logged
ASUS K73 Intel i3 Dual Core 2.3GHz

roarde

  • Vectorian
  • ****
  • Posts: 612
  • move the needle
Re: What's the effect of newline in javascript?
« Reply #3 on: March 31, 2010, 02: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 7.1 Light

roarde

  • Vectorian
  • ****
  • Posts: 612
  • move the needle
Re: What's the effect of newline in javascript?
« Reply #4 on: March 31, 2010, 02:06:45 pm »

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

retired1af

  • Administrator
  • Vectorian
  • *****
  • Posts: 1327
Re: What's the effect of newline in javascript?
« Reply #5 on: March 31, 2010, 02:20:26 pm »

Yepper.
Logged
ASUS K73 Intel i3 Dual Core 2.3GHz

roarde

  • Vectorian
  • ****
  • Posts: 612
  • move the needle
Re: What's the effect of newline in javascript?
« Reply #6 on: April 02, 2010, 02: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 7.1 Light

retired1af

  • Administrator
  • Vectorian
  • *****
  • Posts: 1327
Re: What's the effect of newline in javascript?
« Reply #7 on: April 02, 2010, 03: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