Javascript is unpredictable

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

Javascript is unpredictable

Post 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???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. 'new' is a reserved word..
  2. you may want to post your code.
  3. again 'new' is a reserved word.
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

xudzh
Forum Commoner
Posts: 48
Joined: Sat Feb 19, 2005 6:22 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nope. It feels like home to me.. sorta :)
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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.
Post Reply