Nixing Javascript via javascript: pseudoproto?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bill

    #1

    Nixing Javascript via javascript: pseudoproto?



    This is a question about defensive web browsing. Ocassionally I
    run into a page whose JavaScript does something that I find obnoxious.
    I would like to turn off JavaScript only for that page (instead of
    disabling it globally). It would be cool if there were some way
    to do this through a "bookmarkab le" JavaScript snippet using the
    javascript: pseudoprotocol. Does anyone know any trick to do any
    of this?

    Many thanks!

    -bill


  • Ivo

    #2
    Re: Nixing Javascript via javascript: pseudoproto?

    "bill" wrote[color=blue]
    > This is a question about defensive web browsing. Ocassionally I
    > run into a page whose JavaScript does something that I find obnoxious.
    > I would like to turn off JavaScript only for that page (instead of
    > disabling it globally). It would be cool if there were some way
    > to do this through a "bookmarkab le" JavaScript snippet using the
    > javascript: pseudoprotocol. Does anyone know any trick to do any
    > of this?[/color]

    The following bookmarklet code removes all scripts and all event
    definitions, then reloads the cleaned up page:

    javascript:if(f rames.length){a lert('Sorry, doesn\'t work in
    frames');}else{ onerror=functio n(){return
    true};while((es =document.getEl ementsByTagName ('script')).len gth){es[0].paren
    tNode.removeChi ld(es[0]);}es=document. all;for(i=0;i<e s.length;++i){e =es[i];f
    or(p in
    e){if(!p.indexO f('on')&&e[p]){e[p]=null;}}}docume nt.write(docume nt.documentE
    lement.outerHTM L);document.clo se();onerror=fu nction(){return true};}void 0;

    HTH
    Ivo


    Comment

    • bill

      #3
      Re: Nixing Javascript via javascript: pseudoproto?

      In <40ec5ed8$0$144 $18b6e80@news.w anadoo.nl> "Ivo" <no@thank.you > writes:
      [color=blue]
      >"bill" wrote[color=green]
      >> This is a question about defensive web browsing. Ocassionally I
      >> run into a page whose JavaScript does something that I find obnoxious.
      >> I would like to turn off JavaScript only for that page (instead of
      >> disabling it globally). It would be cool if there were some way
      >> to do this through a "bookmarkab le" JavaScript snippet using the
      >> javascript: pseudoprotocol. Does anyone know any trick to do any
      >> of this?[/color][/color]
      [color=blue]
      >The following bookmarklet code removes all scripts and all event
      >definitions, then reloads the cleaned up page:[/color]
      [color=blue]
      >javascript:if( frames.length){ alert('Sorry, doesn\'t work in
      >frames');}else {onerror=functi on(){return
      >true};while((e s=document.getE lementsByTagNam e('script')).le ngth){es[0].paren
      >tNode.removeCh ild(es[0]);}es=document. all;for(i=0;i<e s.length;++i){e =es[i];f
      >or(p in
      >e){if(!p.index Of('on')&&e[p]){e[p]=null;}}}docume nt.write(docume nt.documentE
      >lement.outerHT ML);document.cl ose();onerror=f unction(){retur n true};}void 0;[/color]

      Way cool! Very handy.

      Thanks!

      -bill

      Comment

      Working...