Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7564269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:51:55+00:00 2026-05-30T13:51:55+00:00

I try to simulate a problem where a script that is loaded from an

  • 0

I try to simulate a problem where a script that is loaded from an external url stops execution of any more scripts on my site.

I tried to simulate such a problem by calling a function that does not exits. I can see the error in firebug but different scripts on the page are still executed.

Are there different kinds of errors in Javascripts? If yes: what kind of error stops script execution? I only need this answer for Firefox.

EDIT

This question is easy to misunderstood but Rob W got it: I need to throw an exception and that exception needs to stop further script execution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:51:56+00:00Added an answer on May 30, 2026 at 1:51 pm

    Answer to the title: No
    Answer to “Are there different kinds of errors in JavaScript**: Yes, see MDN: Error
    Syntax errors will prevent a whole script block from being executed,
    other errors (TypeErrors, Reference errors) will only stop the execution after the occurrence of the error.

    Different <script> blocks are executed separately. You cannot prevent the second block from execution by throwing an error in the first block (Demo: http://jsfiddle.net/WJCEN/).

    <script>Example: Syntax error in this script.</script>
    <script>console.log('Still executed.')</script>
    

    Also, if an error is caught using try-catch (demo: http://jsfiddle.net/WJCEN/1/), then the error will not even stop the execution a whole block.

    try {throw 'Code';}catch(e){}
    console.log('Still executed');
    

    There is no general one-fit-all method to stop all code from running. For individual scripts, you can use some tricks to prevent the code from running further.

    Example 1 (demo): Temporary overwrite a method

    1: <script>window._alert = alert;alert=null;</script>
    2: <script>alert('Some code!');confirm('Not executing');</script>
    3: <script>alert=_alert;delete window._alert;alert('Done!');</script>
    

    This method is based on the fact that script 2 expects alert to be a function. We have rewritten alert to a non-function property (script 1). Script 2 throws a TypeError, and the second block is skipped.
    We restore the original values in script 3.

    Example 2 (demo): Define a constant method, which cannot be overwritten.

    4. <script>Object.defineProperty(window, 'test',{value:null});</script>
    5. <script>var test=function(){alert('Test');};test();alert('What?');</script>
    

    This methods relies on the Object.defineProperty method, to effectively define a constant value. In strict mode, the var test declaration would throw a TypeError: “test is read-only”.
    When strict mode is not enables, a TypeError will be thrown at test(): “test is not a function” (because we defined test to be constant, in script 4).

    Note: The last method is not working correctly with function declarations (see bug #115452, Chrome 17)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to simulate a try-finally or try-except in a language that
I am trying to write a very simple script that would simulate a pocket
try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that
I am coding a little script to save some data from Internet every single
I'm trying to develop an application that will simulate a route through Google's Navigation
On our MOSS Enterprise environment, we have a strange problem. From time to time,
I'm trying to retrive some data from a web site . I wrote a
I often try to fix bugs that occur when I use my iphone for
I have the following problem: I want to simulate some control engineering system. As
I write a method to simulate key press from KeyEvent, like below: private Robot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.