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


Groups > comp.lang.javascript > #7627

Re: function call location?

From Dr J R Stockton <reply1142@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: function call location?
Date 2011-10-22 18:43 +0100
Organization Home
Message-ID <Iw2tVDKADwoOFwho@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <iVY38EH54GoOFwnv@invalid.uk.co.demon.merlyn.invalid> <20ecde0b-c4e3-44df-9e34-a447753b0fb9@g16g2000yqa.googlegroups.com>

Show all headers | View raw


In comp.lang.javascript message <20ecde0b-c4e3-44df-9e34-a447753b0fb9@g1
6g2000yqa.googlegroups.com>, Thu, 20 Oct 2011 17:13:28, Antony Scriven
<adscriven@gmail.com> posted:

>On Oct 20, 7:53 pm, Dr J R Stockton wrote:
>
> > Within a function body, and without using any of the
> > arguments provided in the call of the function, can the
> > function obtain a reference to the script element from
> > within which it was called, and if so how?  The script
> > element containing the definition of the function is of
> > no interest.
>
>In Firefox, for example, you might be able to do something
>with e.stack:
>
>    <html>
>    <body>
>    <script id="foo">
>        var f = function(){
>            try{
>                qwoazlskjfalksdtjo4tjwf();
>            }catch(e){
>                alert(e.stack);
>                alert(window.documentElement.innerHTML);
>            }
>        };
>    </script
>    <script id="bar">
>        f();
>    </script>
>    </body>
>    </html>

As posted, that shows     f();    in the window in FF 7.0.1 Win XP sp3.
After the obvious repair, it gives the first alert, then the error
message
    Error: window.documentElement is undefined
    Source File: file:///C:/HOMEPAGE/$1.htm                     Line: 10


>What's your goal? --Antony

The alert routine always used to pop up s simple dialogue, which could
be dragged around.  Except for Opera, it was alas in the small font used
by Windows for the main menu bar.  The page issuing the alert was
unchanged, apart from having lost focus.

A few updates ago, Opera changed to giving a non-standard but still
draggable alert dialogue, and greying the page into near unreadability -
which is bad if the alert is reporting details of an input error as is
commonly the case.  It retained the more readable font.  My easy fix was
to not use Opera for such pages.

Since my most recent Firefox upgrade, from 3.6.23 to 7.0.1, FF's alert
is like opera's, except that it is not draggable (so may cover what one
wants to read) and uses the hard-to-read font.

My Web site has, counting with MiniTrue, 566 calls of alert.

So I was thinking of replacing window.alert with another function Alert
or by editing replace calls of alert with ones of Alert by editing the
source (with MiniTrue).  The new function Alert would insert a suitable
box somewhere on the page.  In practice, inserting before or after the
script element could be a good default (a second argument, if provided,
would choose a location).  Alternatively, the function Alert could open
a new window.

The same would apply to window.confirm and window.prompt.

<FAQENTRY> replacement for alert confirm prompt </FAQENTRY>

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike 6.05  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 <URL: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

function call location? Dr J R Stockton <reply1142@merlyn.demon.co.uk> - 2011-10-20 19:53 +0100
  Re: function call location? Antony Scriven <adscriven@gmail.com> - 2011-10-20 17:13 -0700
    Re: function call location? Dr J R Stockton <reply1142@merlyn.demon.co.uk> - 2011-10-22 18:43 +0100
      Re: function call location? Scott Sauyet <scott.sauyet@gmail.com> - 2011-10-23 10:00 -0700
        Re: function call location? Dr J R Stockton <reply1143@merlyn.demon.co.uk> - 2011-10-24 19:43 +0100
          Re: function call location? Scott Sauyet <scott.sauyet@gmail.com> - 2011-10-25 05:13 -0700
            Re: function call location? Dr J R Stockton <reply1143@merlyn.demon.co.uk> - 2011-10-26 20:13 +0100
      Re: function call location? Antony Scriven <adscriven@gmail.com> - 2011-10-24 02:11 -0700
        Re: function call location? Dr J R Stockton <reply1143@merlyn.demon.co.uk> - 2011-10-25 19:28 +0100
          Re: function call location? Scott Sauyet <scott.sauyet@gmail.com> - 2011-10-26 05:09 -0700
            Re: function call location? Dr J R Stockton <reply1143@merlyn.demon.co.uk> - 2011-10-27 19:27 +0100
              Re: function call location? Antony Scriven <adscriven@gmail.com> - 2011-10-27 17:25 -0700
                Re: function call location? Dr J R Stockton <reply1143@merlyn.demon.co.uk> - 2011-10-29 20:36 +0100

csiph-web