javascript Alert() on Firefox - No Sound

Discussion in 'NZ Computing' started by JohnO, Apr 3, 2008.

  1. JohnO

    JohnO Guest

    Hi All,

    If I embed this in a web page, I get a popup window that should make
    the windows beep sound. This works in InternetExploder, but on FireFox
    I get no sound. Any idea why that would be?

    <script>
    alert("let there be sound");
    </script>

    TIA,
    JohnO
     
    JohnO, Apr 3, 2008
    #1
    1. Advertising

  2. JohnO

    Ralph Fox Guest

    On Wed, 2 Apr 2008 20:47:08 -0700 (PDT), in message <>,
    JohnO wrote:

    > If I embed this in a web page, I get a popup window


    Which you do, of course.

    > that should make
    > the windows beep sound.


    Er, _why_ should it make the windows beep sound?


    > This works in InternetExploder, but on FireFox
    > I get no sound. Any idea why that would be?


    1. IE uses the Windows MessageBox API to show the pop-up.
    The MessageBox API, as well as showing a pop-up, also makes a sound.

    2. Firefox does not use the Windows MessageBox API for this.

    3. There is no requirement to make a sound. This is simply one of the
    differences between browsers.


    > <script>
    > alert("let there be sound");
    > </script>
    >
    > TIA,
    > JohnO



    --
    Cheers,
    Ralph
     
    Ralph Fox, Apr 3, 2008
    #2
    1. Advertising

  3. JohnO

    JohnO Guest

    On Apr 3, 9:00 pm, Ralph Fox <> wrote:
    > On Wed, 2 Apr 2008 20:47:08 -0700 (PDT), in message <>,
    >
    > JohnO wrote:
    > > If I embed this in a web page, I get a popup window

    >
    > Which you do, of course.
    >
    > > that should make
    > > the windows beep sound.

    >
    > Er, _why_ should it make the windows beep sound?
    >
    > > This works in InternetExploder, but on FireFox
    > > I get no sound. Any idea why that would be?

    >
    > 1.  IE uses the Windows MessageBox API to show the pop-up.
    >     The MessageBox API, as well as showing a pop-up, also makes a sound.
    >
    > 2.  Firefox does not use the Windows MessageBox API for this.
    >
    > 3.  There is no requirement to make a sound.  This is simply one of the
    >     differences between browsers.
    >
    > > <script>
    > > alert("let there be sound");
    > > </script>

    >
    > > TIA,
    > > JohnO

    >
    > --
    > Cheers,
    > Ralph


    Ok, I can get around it by detecting the browser:
    <SCRIPT>
    var browser = navigator.appName;
    if (browser=="Netscape")
    {
    java.awt.Toolkit.getDefaultToolkit().beep();
    }
    alert("Error Message");
    </SCRIPT>
     
    JohnO, Apr 3, 2008
    #3
  4. In article
    <>, JohnO
    did write:

    > if (browser=="Netscape")


    Yuk. Please, check directly for the functionality you need, not for some
    purely informational name.
     
    Lawrence D'Oliveiro, Apr 3, 2008
    #4
  5. JohnO

    JohnO Guest

    On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    central.gen.new_zealand> wrote:
    > In article
    > <>, JohnO
    > did write:
    >
    > > if (browser=="Netscape")

    >
    > Yuk. Please, check directly for the functionality you need, not for some
    > purely informational name.


    Go on then, explain exactly how to do that, please.
     
    JohnO, Apr 3, 2008
    #5
  6. In article
    <>, JohnO
    did write:

    > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > central.gen.new_zealand> wrote:
    >
    >> In article
    >> <>,
    >> JohnO did write:
    >>
    >> > if (browser=="Netscape")

    >>
    >> Yuk. Please, check directly for the functionality you need, not for some
    >> purely informational name.

    >
    > Go on then, explain exactly how to do that, please.


    Check for the existence of those objects before trying to use them.
     
    Lawrence D'Oliveiro, Apr 4, 2008
    #6
  7. JohnO

    JohnO Guest

    On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    central.gen.new_zealand> wrote:
    > In article
    > <>, JohnO
    > did write:
    >
    > > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > > central.gen.new_zealand> wrote:

    >
    > >> In article
    > >> <>,
    > >> JohnO did write:

    >
    > >> > if (browser=="Netscape")

    >
    > >> Yuk. Please, check directly for the functionality you need, not for some
    > >> purely informational name.

    >
    > > Go on then, explain exactly how to do that, please.

    >
    > Check for the existence of those objects before trying to use them.


    But it is not so much exisetnce of objects that I am interested in.
    All the platforms support the alert() method, but not all of them make
    a sound, and it doesn't seem to be documented which do. I have
    determined that FF does not and IE does at the moment. So it appears
    the test is about the browser not the objects.
     
    JohnO, Apr 4, 2008
    #7
  8. In article
    <>, JohnO
    did write:

    > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    > central.gen.new_zealand> wrote:
    >> In article
    >> <>,
    >> JohnO did write:
    >>
    >> > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    >> > central.gen.new_zealand> wrote:

    >>
    >> >> In article
    >> >> <>,
    >> >> JohnO did write:

    >>
    >> >> > if (browser=="Netscape")

    >>
    >> >> Yuk. Please, check directly for the functionality you need, not for
    >> >> some purely informational name.

    >>
    >> > Go on then, explain exactly how to do that, please.

    >>
    >> Check for the existence of those objects before trying to use them.

    >
    > But it is not so much exisetnce of objects that I am interested in.
    > All the platforms support the alert() method, but not all of them make
    > a sound, and it doesn't seem to be documented which do. I have
    > determined that FF does not and IE does at the moment. So it appears
    > the test is about the browser not the objects.


    But you are calling specific objects to get the sound, are you not?
    Therefore, test for those objects.
     
    Lawrence D'Oliveiro, Apr 4, 2008
    #8
  9. JohnO

    JohnO Guest

    On Apr 4, 4:20 pm, Lawrence D'Oliveiro <l...@geek-
    central.gen.new_zealand> wrote:
    > In article
    > <>, JohnO
    > did write:
    >
    >
    >
    > > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    > > central.gen.new_zealand> wrote:
    > >> In article
    > >> <>,
    > >> JohnO did write:

    >
    > >> > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > >> > central.gen.new_zealand> wrote:

    >
    > >> >> In article
    > >> >> <>,
    > >> >> JohnO did write:

    >
    > >> >> > if (browser=="Netscape")

    >
    > >> >> Yuk. Please, check directly for the functionality you need, not for
    > >> >> some purely informational name.

    >
    > >> > Go on then, explain exactly how to do that, please.

    >
    > >> Check for the existence of those objects before trying to use them.

    >
    > > But it is not so much exisetnce of objects that I am interested in.
    > > All the platforms support the alert() method, but not all of them make
    > > a sound, and it doesn't seem to be documented which do. I have
    > > determined that FF does not and IE does at the moment. So it appears
    > > the test is about the browser not the objects.

    >
    > But you are calling specific objects to get the sound, are you not?
    > Therefore, test for those objects.


    The object that I am interested in is the alert() method of the
    javascript Window object and that is there in all cases, so testing
    for it's existence doesn't help me. My issue is that the alert()
    method on non IE browsers is silent so I need to know what the browser
    is, not whether the object exists.

    Do you mean testing for the existence of the java objects? Interesting
    but probably not the solution as they could be there whether the
    alert() method is silent or not.

    Anyway, how do you test for existence of an object? Reference it and
    catch an exception if it is not there?
     
    JohnO, Apr 4, 2008
    #9
  10. On Apr 4, 1:13 pm, JohnO <> wrote:
    > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    >
    >
    >
    >
    >
    > central.gen.new_zealand> wrote:
    > > In article
    > > <>, JohnO
    > > did write:

    >
    > > > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > > > central.gen.new_zealand> wrote:

    >
    > > >> In article
    > > >> <>,
    > > >> JohnO did write:

    >
    > > >> > if (browser=="Netscape")

    >
    > > >> Yuk. Please, check directly for the functionality you need, not for some
    > > >> purely informational name.

    >
    > > > Go on then, explain exactly how to do that, please.

    >
    > > Check for the existence of those objects before trying to use them.

    >
    > But it is not so much exisetnce of objects that I am interested in.
    > All the platforms support the alert() method, but not all of them make
    > a sound, and it doesn't seem to be documented which do. I have
    > determined that FF does not and IE does at the moment. So it appears
    > the test is about the browser not the objects.- Hide quoted text -
    >
    > - Show quoted text -


    If the object doesn't exist then code execution will fail, so it's a
    good idea to check. The point is not to assume. You want to do
    something like this:

    <script language="javascript">
    function alertWithBeep(s) {
    if( navigator.appName=="Netscape" && typeof(java)=="object") {
    java.awt.Toolkit.getDefaultToolkit().beep();
    }
    alert(s);
    }

    // test!
    alertWithBeep("HI!");
    </script>

    So it only tries to 'beep' if we think the browser is Netscape and the
    java object exists.
     
    Hamish Campbell, Apr 4, 2008
    #10
  11. On Apr 4, 4:57 pm, JohnO <> wrote:
    > On Apr 4, 4:20 pm, Lawrence D'Oliveiro <l...@geek-
    >
    >
    >
    >
    >
    > central.gen.new_zealand> wrote:
    > > In article
    > > <>, JohnO
    > > did write:

    >
    > > > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    > > > central.gen.new_zealand> wrote:
    > > >> In article
    > > >> <>,
    > > >> JohnO did write:

    >
    > > >> > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > > >> > central.gen.new_zealand> wrote:

    >
    > > >> >> In article
    > > >> >> <>,
    > > >> >> JohnO did write:

    >
    > > >> >> > if (browser=="Netscape")

    >
    > > >> >> Yuk. Please, check directly for the functionality you need, not for
    > > >> >> some purely informational name.

    >
    > > >> > Go on then, explain exactly how to do that, please.

    >
    > > >> Check for the existence of those objects before trying to use them.

    >
    > > > But it is not so much exisetnce of objects that I am interested in.
    > > > All the platforms support the alert() method, but not all of them make
    > > > a sound, and it doesn't seem to be documented which do. I have
    > > > determined that FF does not and IE does at the moment. So it appears
    > > > the test is about the browser not the objects.

    >
    > > But you are calling specific objects to get the sound, are you not?
    > > Therefore, test for those objects.

    >
    > The object that I am interested in is the alert() method of the
    > javascript Window object and that is there in all cases, so testing
    > for it's existence doesn't help me. My issue is that the alert()
    > method on non IE browsers is silent so I need to know what the browser
    > is, not whether the object exists.
    >
    > Do you mean testing for the existence of the java objects? Interesting
    > but probably not the solution as they could be there whether the
    > alert() method is silent or not.
    >
    > Anyway, how do you test for existence of an object? Reference it and
    > catch an exception if it is not there?- Hide quoted text -
    >
    > - Show quoted text -


    The java object, not 'alert'.
     
    Hamish Campbell, Apr 4, 2008
    #11
  12. JohnO

    JohnO Guest

    On Apr 4, 4:57 pm, Hamish Campbell <> wrote:
    > On Apr 4, 1:13 pm, JohnO <> wrote:
    >
    >
    >
    > > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-

    >
    > > central.gen.new_zealand> wrote:
    > > > In article
    > > > <>, JohnO
    > > > did write:

    >
    > > > > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > > > > central.gen.new_zealand> wrote:

    >
    > > > >> In article
    > > > >> <>,
    > > > >> JohnO did write:

    >
    > > > >> > if (browser=="Netscape")

    >
    > > > >> Yuk. Please, check directly for the functionality you need, not for some
    > > > >> purely informational name.

    >
    > > > > Go on then, explain exactly how to do that, please.

    >
    > > > Check for the existence of those objects before trying to use them.

    >
    > > But it is not so much exisetnce of objects that I am interested in.
    > > All the platforms support the alert() method, but not all of them make
    > > a sound, and it doesn't seem to be documented which do. I have
    > > determined that FF does not and IE does at the moment. So it appears
    > > the test is about the browser not the objects.- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > If the object doesn't exist then code execution will fail, so it's a
    > good idea to check. The point is not to assume. You want to do
    > something like this:
    >
    > <script language="javascript">
    > function alertWithBeep(s) {
    > if( navigator.appName=="Netscape" && typeof(java)=="object") {
    > java.awt.Toolkit.getDefaultToolkit().beep();
    > }
    > alert(s);
    >
    > }
    >
    > // test!
    > alertWithBeep("HI!");
    > </script>
    >
    > So it only tries to 'beep' if we think the browser is Netscape and the
    > java object exists.


    Cheers Hamish.
     
    JohnO, Apr 4, 2008
    #12
  13. JohnO

    JohnO Guest

    On Apr 4, 4:59 pm, Hamish Campbell <> wrote:
    > On Apr 4, 4:57 pm, JohnO <> wrote:
    >
    >
    >
    > > On Apr 4, 4:20 pm, Lawrence D'Oliveiro <l...@geek-

    >
    > > central.gen.new_zealand> wrote:
    > > > In article
    > > > <>, JohnO
    > > > did write:

    >
    > > > > On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    > > > > central.gen.new_zealand> wrote:
    > > > >> In article
    > > > >> <>,
    > > > >> JohnO did write:

    >
    > > > >> > On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    > > > >> > central.gen.new_zealand> wrote:

    >
    > > > >> >> In article
    > > > >> >> <>,
    > > > >> >> JohnO did write:

    >
    > > > >> >> > if (browser=="Netscape")

    >
    > > > >> >> Yuk. Please, check directly for the functionality you need, not for
    > > > >> >> some purely informational name.

    >
    > > > >> > Go on then, explain exactly how to do that, please.

    >
    > > > >> Check for the existence of those objects before trying to use them.

    >
    > > > > But it is not so much exisetnce of objects that I am interested in.
    > > > > All the platforms support the alert() method, but not all of them make
    > > > > a sound, and it doesn't seem to be documented which do. I have
    > > > > determined that FF does not and IE does at the moment. So it appears
    > > > > the test is about the browser not the objects.

    >
    > > > But you are calling specific objects to get the sound, are you not?
    > > > Therefore, test for those objects.

    >
    > > The object that I am interested in is the alert() method of the
    > > javascript Window object and that is there in all cases, so testing
    > > for it's existence doesn't help me. My issue is that the alert()
    > > method on non IE browsers is silent so I need to know what the browser
    > > is, not whether the object exists.

    >
    > > Do you mean testing for the existence of the java objects? Interesting
    > > but probably not the solution as they could be there whether the
    > > alert() method is silent or not.

    >
    > > Anyway, how do you test for existence of an object? Reference it and
    > > catch an exception if it is not there?- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > The java object, not 'alert'.


    Hi Hamish,

    I saw your other post - thanks for that.

    The thing that you get but Larrry doesn't seem to, is that the browser
    name is significant.
     
    JohnO, Apr 4, 2008
    #13
  14. In article
    <>, JohnO
    did write:

    > The thing that you get but [Lawrence] doesn't seem to, is that the browser
    > name is significant.


    Don't depend on that, I said.
     
    Lawrence D'Oliveiro, Apr 4, 2008
    #14
  15. In article
    <>, Hamish
    Campbell did write:

    > if( navigator.appName=="Netscape" && typeof(java)=="object") {
    > java.awt.Toolkit.getDefaultToolkit().beep();
    > }


    I would leave off the appName check.
     
    Lawrence D'Oliveiro, Apr 4, 2008
    #15
  16. JohnO

    JohnO Guest

    On Apr 4, 5:18 pm, Lawrence D'Oliveiro <l...@geek-
    central.gen.new_zealand> wrote:
    > In article
    > <>, Hamish
    > Campbell did write:
    >
    > >     if( navigator.appName=="Netscape" && typeof(java)=="object") {
    > >         java.awt.Toolkit.getDefaultToolkit().beep();
    > >     }

    >
    > I would leave off the appName check.


    No. The java object existing does not guarantee that the alert() is
    silent. This could lead to a double beep.
     
    JohnO, Apr 4, 2008
    #16
  17. In article
    <>, JohnO
    did write:

    > No. The java object existing does not guarantee that the alert() is
    > silent. This could lead to a double beep.


    Think of it as God trying to tell you something.
     
    Lawrence D'Oliveiro, Apr 4, 2008
    #17
  18. JohnO

    Enkidu Guest

    Lawrence D'Oliveiro wrote:
    > In article
    > <>,
    > JohnO did write:
    >
    >> On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    >> central.gen.new_zealand> wrote:
    >>> In article
    >>> <>,
    >>> JohnO did write:
    >>>
    >>>> On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    >>>> central.gen.new_zealand> wrote:
    >>>>> In article
    >>>>> <>,
    >>>>> JohnO did write:
    >>>>>> if (browser=="Netscape")
    >>>>> Yuk. Please, check directly for the functionality you need,
    >>>>> not for some purely informational name.
    >>>> Go on then, explain exactly how to do that, please.
    >>> Check for the existence of those objects before trying to use
    >>> them.

    >> But it is not so much exisetnce of objects that I am interested in.
    >> All the platforms support the alert() method, but not all of them
    >> make a sound, and it doesn't seem to be documented which do. I have
    >> determined that FF does not and IE does at the moment. So it
    >> appears the test is about the browser not the objects.

    >
    > But you are calling specific objects to get the sound, are you not?
    > Therefore, test for those objects.
    >

    As I read it, he is not. He is calling alert() and it behaves
    differently in FF to what it does in IE. Using the URL
    'javascript:alert("Hullo World!")' in FF does not result in a bleep. I
    can't test in IE since I don't have a Windows platform here, but he says
    it does result in a beep in IE.

    Cheers,

    Cliff

    --

    Have you ever noticed that if something is advertised as 'amusing' or
    'hilarious', it usually isn't?
     
    Enkidu, Apr 5, 2008
    #18
  19. JohnO

    Enkidu Guest

    Hamish Campbell wrote:
    > On Apr 4, 1:13 pm, JohnO <> wrote:
    >> On Apr 4, 12:49 pm, Lawrence D'Oliveiro <l...@geek-
    >>
    >>
    >>
    >>
    >>
    >> central.gen.new_zealand> wrote:
    >>> In article
    >>> <>, JohnO
    >>> did write:
    >>>> On Apr 4, 11:38 am, Lawrence D'Oliveiro <l...@geek-
    >>>> central.gen.new_zealand> wrote:
    >>>>> In article
    >>>>> <>,
    >>>>> JohnO did write:
    >>>>>> if (browser=="Netscape")
    >>>>> Yuk. Please, check directly for the functionality you need, not for some
    >>>>> purely informational name.
    >>>> Go on then, explain exactly how to do that, please.
    >>> Check for the existence of those objects before trying to use them.

    >> But it is not so much exisetnce of objects that I am interested in.
    >> All the platforms support the alert() method, but not all of them make
    >> a sound, and it doesn't seem to be documented which do. I have
    >> determined that FF does not and IE does at the moment. So it appears
    >> the test is about the browser not the objects.- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > If the object doesn't exist then code execution will fail, so it's a
    > good idea to check. The point is not to assume. You want to do
    > something like this:
    >
    > <script language="javascript">
    > function alertWithBeep(s) {
    > if( navigator.appName=="Netscape" && typeof(java)=="object") {
    > java.awt.Toolkit.getDefaultToolkit().beep();
    > }
    > alert(s);
    > }
    >
    > // test!
    > alertWithBeep("HI!");
    > </script>
    >
    > So it only tries to 'beep' if we think the browser is Netscape and the
    > java object exists.
    >

    Maybe I'm missing something. Why test whether the Java beep is
    implemented if he is using the Javascript beep?

    Cheers,

    Cliff

    --

    Have you ever noticed that if something is advertised as 'amusing' or
    'hilarious', it usually isn't?
     
    Enkidu, Apr 5, 2008
    #19
  20. JohnO

    Enkidu Guest

    Lawrence D'Oliveiro wrote:
    > In article
    > <>, JohnO
    > did write:
    >
    >> No. The java object existing does not guarantee that the alert() is
    >> silent. This could lead to a double beep.

    >
    > Think of it as God trying to tell you something.
    >

    Like don't use FF because it doesn't produce the 'beep' that you want?

    http://xkcd.com/198/

    Cheers,

    Cliff

    --

    Have you ever noticed that if something is advertised as 'amusing' or
    'hilarious', it usually isn't?
     
    Enkidu, Apr 5, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xplorer

    Firefox javascript problems

    Xplorer, Jun 3, 2004, in forum: Firefox
    Replies:
    1
    Views:
    585
    Quivis
    Jun 3, 2004
  2. Sam Salt

    Firefox & ?? Javascript

    Sam Salt, Feb 22, 2005, in forum: Firefox
    Replies:
    0
    Views:
    430
    Sam Salt
    Feb 22, 2005
  3. Toronto Garage Door Company

    ALERT: Virus Scam Alert!

    Toronto Garage Door Company, Nov 18, 2003, in forum: Computer Support
    Replies:
    1
    Views:
    793
    andre
    Nov 18, 2003
  4. =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?=

    Alert..General Alert?..New Discovery?.

    =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?=, Jul 24, 2007, in forum: Wireless Networking
    Replies:
    0
    Views:
    577
    =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?=
    Jul 24, 2007
  5. Shane

    To Javascript, or not to Javascript

    Shane, Aug 29, 2005, in forum: NZ Computing
    Replies:
    5
    Views:
    491
    Waylon Kenning
    Aug 30, 2005
Loading...

Share This Page