Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #24162

Re: intercept an alert

From Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: intercept an alert
Date 2014-05-13 18:00 +0100
Organization Home
Message-ID <8R65vYRo+kcTFwRW@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <862dneogqrcsze3OnZ2dnUVZ_gCdnZ2d@westnet.com.au>

Show all headers | View raw


In comp.lang.javascript message <862dneogqrcsze3OnZ2dnUVZ_gCdnZ2d@westne
t.com.au>, Mon, 12 May 2014 14:38:33, Andrew Poulos
<ap_prog@hotmail.com> posted:

>I've been using a 3rd party web platform to build a web site.
>
>The platform can display its own alerts.
>
>I need to prevent one of the alerts but as I have no access to the code
>that is generating the alert so I'm wondering if there's a way to
>intercept it.
>
>If its the message in question then it is to be prevented from
>displaying otherwise the alert displays as "normal".
>
>I thought of doing
>
>window.alert = function(msg){
>  if (msg.indexOf('Is empty') != -1) {
>    return false;
>  } else {
>    // what here
>  }
>};
>
>but to overwrite the normal function what goes in "what here"?


Consider the implications of

        Fred = window.alert
        function Bert(X) { Fred("*** " + X + " ***") }
        window.alert = Bert
        alert(333)

which alerts "*** 333 ***".

The code will probably cause an Eruption of the Lahn; but that is
nowadays a customary side-effect.

-- 
 (c) John Stockton, nr London, UK.  For Mail, see Home Page.  Turnpike, WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6;  see my <http://www.merlyn.demon.co.uk/pc-links.htm>.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

intercept an alert Andrew Poulos <ap_prog@hotmail.com> - 2014-05-12 14:38 +1000
  Re: intercept an alert Andrew Poulos <ap_prog@hotmail.com> - 2014-05-12 15:35 +1000
    Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 11:32 +0200
      Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 12:29 +0200
        Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 13:30 +0200
        Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 14:54 +0200
          Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 15:36 +0200
            Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 15:40 +0200
              Re: intercept an alert Simon Lewis <simonlewis2001@gmail.com> - 2014-05-12 15:43 +0200
                Re: intercept an alert "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-12 16:19 +0200
          Re: intercept an alert Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-12 19:35 +0200
    Re: intercept an alert garrett.smith@acxiom.com - 2014-05-14 09:57 -0700
  Re: intercept an alert Dr J R Stockton <reply1400@merlyn.demon.co.uk.invalid> - 2014-05-13 18:00 +0100
  Re: intercept an alert garrett.smith@acxiom.com - 2014-05-14 09:57 -0700

csiph-web