Results 1 to 6 of 6

Thread: Force all JS to 'pause'?

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Force all JS to 'pause'?

    I had an idea for a JS bookmarklet: something to disable all JS on a page.

    The reason would be to stop unexpected things from happening, especially ads with sound. I'm talking about rotating ads, not just static flash ads.

    This might be useful for other reasons as well.

    In PHP, $GLOBALS contains all of the active variables-- everything. By looping through the array, you could remove all of this and effectively disable most things.

    My knowledge of JS isn't strong enough to find an equivalent (perhaps window. or document.?), but if someone has an idea that would work to disable all active processes, that would be great. I imagine that looping functions would cause more trouble than just unsetting all variables, but perhaps there's a way.

    Or, alternatively is there any code that is guaranteed to crash JS? Or make it pause (like sleep() in PHP)?

    Just attach this to a bookmarklet and it would probably be very popular.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The browser has this. Any particular browser(s) you have in mind?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sorry, I should be more specific:
    I want to block JS at a specific time (an off button) for a particular window (or tab).

    Now that I think about it the idea of crashing JS probably won't work for just a single window. It would crash for the whole browser.

    Disabling JS at the browser level is very problematic because JS is useful except when it's used for ads and other things that pop up annoyingly. So disabling it for a problematic window (without having to close that window, but while keeping JS active for the other windows) would be great.


    Now if there is some method available in the browser, that would be fine too. I'm using Firefox (though if this works in other browsers, I wouldn't mind knowing about that either).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I don't think you can disable javascript for a window. You can disable/enable javascript for the browser. Good news is that most javascript that's disabled after it's initialized will resume from where it left off once javascript is re-enabled.

    In Firefox use developer's tools > Disable > Disable JavaScript > All JavaScript.

    It's a toggle. I dunno what it is in FireBug. With or without either, you can always - from the native Firefox menu:

    Tools > Options > Content > Enable JavaScript

    It's also a toggle (a checkbox), and there's an advanced button there that lets you pick and choose among some javascript features.
    Last edited by jscheuer1; 11-27-2010 at 05:53 AM. Reason: English usage
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    djr33 (11-26-2010)

  6. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    But you don't have any ideas about a bookmarklet that would block it for a certain window?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Following up, I haven't found anything particularly useful. One method that works well is alert() and it pauses everything that's going on. At least in firefox, this still allows you to use the other windows as well. The only problem is that it pauses the entire window, including all tabs. So in order to leave a window paused, that disables all tabs; in other words, you must use separate windows rather than tabs. Aside from that, it's a perfect solution.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •