Page 1 of 1

Javascript is unpredictable

Posted: Tue Mar 01, 2005 5:34 pm
by xudzh
5 min ago, i was trying to build a new script.

I typed

Code: Select all

javascript:var new=window.open('index.php');  void 0;
into the address bar and poped up a new window.

Now when i type that same code, i got error!

"expected identifer"

if the change "new" to another variable name, it works fine.

Then i change it back to "new" and I got the same error.

How is that...

2.I have a code with some errors. In different days it would return different errors.

3. new=window.open('index.php'); void 0;
then i type

Code: Select all

new.document.formsї0].submit(); void 0
and got an error says syntax error!

if i remove "new." then syntax error is gone.
So i concluded that using "document" as a property of an object will cause an syntax error???

Posted: Tue Mar 01, 2005 5:39 pm
by feyd
  1. 'new' is a reserved word..
  2. you may want to post your code.
  3. again 'new' is a reserved word.

Posted: Wed Mar 02, 2005 10:14 am
by PrObLeM

Posted: Fri Mar 04, 2005 6:30 pm
by xudzh
You're both right, i'm such I idoit.

Is it true that javascript is harder than php? That's what i feel

Posted: Fri Mar 04, 2005 7:47 pm
by feyd
nope. It feels like home to me.. sorta :)

Posted: Sat Mar 05, 2005 3:56 am
by patrikG
only thing with Javascript is: some browsers are non-standard compliant (IE being the prime example - try regEx in IE for the first time and you'll see what I mean.) Otherwise: JS is powerful and not really difficult. For a long time time it's been viewed as an ancillary programming toy, but with internet applications becoming more mature, it's slowly being regarded as offering powerful enhancements and key functionalities. Best example: any of Google' s web services (i.e. GMail, GoogleAds, etc.). Also A9.com uses JS in a very powerful way.