SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jan 7, 2008, 08:51 #1
- Join Date
- Nov 2005
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is there a way of terminating JavaScript code in it's tracks?
I've been doing lots of Googling and looking in my books, but can't seem to find a function that does this? I'm basically wanting to try some things out in other peoples code and I'm trying to find a way to terminate code dead in it's tracks where I want... Bit like the die() statement in PHP?
Many thanks.
-
Jan 7, 2008, 09:12 #2
- Join Date
- Jan 2005
- Location
- Too far up north
- Posts
- 1,566
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You could always throw an Error if something goes wrong. The JavaScript will stop executing after this. Is that what you want?
Example
Code:// something went terrible wrong throw new Error("Fatal error!");
-
Jan 7, 2008, 09:14 #3
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Install Firebug, select the "script" tab and click in the left margin to set a breakpoint.
-
Jan 7, 2008, 09:28 #4
- Join Date
- Nov 2005
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Jan 7, 2008, 09:55 #5
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can install Firefox. Seriously -- Developing Javascript on IE, is an uphill battle.
If you insist, you can use the IE script debugger.
-
Jan 7, 2008, 10:07 #6
- Join Date
- Nov 2005
- Posts
- 496
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes, I have FireFox... Its my favourite browser. It's just the projects I work on (in my team) have developed the whole thing to work just in IE so I kinda have to use that to debug... IE Script debugger? I'll check that out. Cheers!
Bookmarks