Play a sound when clicking a hyperlink?

Discussion in 'Javascript' started by Chris Ianson, Mar 17, 2006.

  1. Chris Ianson

    Chris Ianson Guest

    Hi, is there a way to play a small sound snippet when a user clicks a
    certain hyperlink hotspot on an image?

    Thanks in advance.
    Chris Ianson, Mar 17, 2006
    #1
    1. Advertising

  2. Chris Ianson

    dorayme Guest

    In article <w3HSf.37636$>,
    "Chris Ianson" <> wrote:

    > Hi, is there a way to play a small sound snippet when a user clicks a
    > certain hyperlink hotspot on an image?
    >
    > Thanks in advance.


    You mean like the first long chord from a Jimi Hendrix's Star
    Spangle maybe?

    --
    dorayme
    dorayme, Mar 18, 2006
    #2
    1. Advertising

  3. Chris Ianson

    Neredbojias Guest

    With neither quill nor qualm, Chris Ianson quothed:

    > Hi, is there a way to play a small sound snippet when a user clicks a
    > certain hyperlink hotspot on an image?


    Image Map and Object, but will the visitor hear it if he/she browses
    with sound off as I suspect many do?

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Mar 18, 2006
    #3
  4. Chris Ianson

    dorayme Guest

    In article <>,
    Neredbojias <> wrote:

    > will the visitor hear it if he/she browses
    > with sound off


    If it is _very_ loud, of course, he/she will....

    --
    dorayme
    dorayme, Mar 18, 2006
    #4
  5. Chris Ianson

    Randy Webb Guest

    Chris Ianson said the following on 3/17/2006 5:51 PM:
    > Hi, is there a way to play a small sound snippet when a user clicks a
    > certain hyperlink hotspot on an image?


    My browser makes a clicking noise already when I click links. It's the
    way *I* want it - not you.

    But, trying to play a sound on a PC without speakers should be an
    entertaining project.

    The answer is no. Well, not in the groups you posted to anyway.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Mar 18, 2006
    #5
  6. Chris Ianson

    Neredbojias Guest

    With neither quill nor qualm, dorayme quothed:

    > In article <>,
    > Neredbojias <> wrote:
    >
    > > will the visitor hear it if he/she browses
    > > with sound off

    >
    > If it is _very_ loud, of course, he/she will....


    If it is very loud, it has to occur. Since it can't occur, it can't be
    loud. My opinion of Martian intelligence has plummeted lately.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Mar 18, 2006
    #6
  7. Chris Ianson

    Chris Ianson Guest

    "Sid Ismail" <> wrote in message
    news:...

    > I also don't like it.
    >
    > Search Google for "playing sound while surfing".


    Perhaps you can all help me add a 'sounds on/off' button to my page then
    also. :)

    What I'd like is a constant looping background MP3 (it will just be quiet
    'street noise'), and a specific sound when they click any hyperlink, but
    that option to turn sounds on/off.

    Anyone here got the know-how?

    Thanks in advance.
    Chris Ianson, Mar 18, 2006
    #7
  8. Chris Ianson

    dorayme Guest

    In article <>,
    Neredbojias <> wrote:

    > With neither quill nor qualm, dorayme quothed:
    >
    > > In article <>,
    > > Neredbojias <> wrote:
    > >
    > > > will the visitor hear it if he/she browses
    > > > with sound off

    > >
    > > If it is _very_ loud, of course, he/she will....

    >
    > If it is very loud, it has to occur. Since it can't occur, it can't be
    > loud. My opinion of Martian intelligence has plummeted lately.


    Boji, you have been badly affected by being in BdeZ's killfile.
    Try to imagine a sound that is so loud that it breaks all logical
    barriers and just roll about the floor in paroxysms of laughter
    at this instead of casting aspersions on Martian intelligence.

    Look, I know it will be bad when you meet Officer Bud White. I
    know it is troubling you. But it will not be the end of the world
    and you will emerge a better and stronger man.

    And, btw, don't stir up that "mad hatter" crowd, a few of their
    threads have (after a long absence) started appearing, complete
    with foul language, on my newsreader.

    --
    dorayme
    dorayme, Mar 19, 2006
    #8
  9. Chris Ianson

    Neredbojias Guest

    With neither quill nor qualm, dorayme quothed:

    > In article <>,
    > Neredbojias <> wrote:
    >
    > > With neither quill nor qualm, dorayme quothed:
    > >
    > > > In article <>,
    > > > Neredbojias <> wrote:
    > > >
    > > > > will the visitor hear it if he/she browses
    > > > > with sound off
    > > >
    > > > If it is _very_ loud, of course, he/she will....

    > >
    > > If it is very loud, it has to occur. Since it can't occur, it can't be
    > > loud. My opinion of Martian intelligence has plummeted lately.

    >
    > Boji, you have been badly affected by being in BdeZ's killfile.
    > Try to imagine a sound that is so loud that it breaks all logical
    > barriers and just roll about the floor in paroxysms of laughter
    > at this instead of casting aspersions on Martian intelligence.


    BdeZ's killfile is like the Devil's Island of the Information Highway.
    You can't imagine the depths of depravity and insouciance suffered by
    denizens of that digital deep. Oh...what am I talking about? You're
    there, too. That explains it.

    > Look, I know it will be bad when you meet Officer Bud White. I
    > know it is troubling you. But it will not be the end of the world
    > and you will emerge a better and stronger man.
    >
    > And, btw, don't stir up that "mad hatter" crowd, a few of their
    > threads have (after a long absence) started appearing, complete
    > with foul language, on my newsreader.


    I don't view them as a crowd, I view each as an individual with a unique
    persona and responsible for his/her own commentary just as anyone would
    be. Casually categorizing people into groups leads to discrimination
    which I have found that Australians in particular are far from free of.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Mar 19, 2006
    #9
  10. Chris Ianson

    Guest

    Hello,

    I don't know what I'm talking about, but might wrapping some text with
    nested links work, one for the web page and one for the sound? Lacking
    that, you could use a Javascript onClick() event handler to redirect
    them after clicking the link, but you'd be dependent on them having
    Jscript turned on (which 95% of people do anyway).
    , Mar 19, 2006
    #10
  11. wrote:

    > Hello,
    >
    > I don't know what I'm talking about, but might wrapping some text with
    > nested links work, one for the web page and one for the sound? Lacking
    > that, you could use a Javascript onClick() event handler to redirect
    > them after clicking the link, but you'd be dependent on them having
    > Jscript turned on (which 95% of people do anyway).
    >


    You cannot nest links...a hack employed by black-hats on the web to do
    very nasty things, up to date modern browsers will not fall for the trick.

    TIP: in the future quote the part of the message that you are replying
    to. Many folks use real newsreaders and not via webpage as Google Groups
    and we do not see all the messages in a thread in a single window.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Mar 19, 2006
    #11
  12. Chris Ianson

    Chris Ianson Guest

    <> wrote in message
    news:...
    > Hello,
    >
    > I don't know what I'm talking about, but might wrapping some text with
    > nested links work, one for the web page and one for the sound? Lacking
    > that, you could use a Javascript onClick() event handler to redirect
    > them after clicking the link, but you'd be dependent on them having
    > Jscript turned on (which 95% of people do anyway).


    Thanks for a sensible reply to my question which was 'how to' do it (not
    'should I' and 'please give your opinion on if it's a bad idea').

    Can you give an example of such code that will call a URL hyperlink and play
    a sound when clicked please.

    Cheers!
    Chris Ianson, Mar 19, 2006
    #12
  13. On Sun, 19 Mar 2006 11:38:25 +0100, Chris Ianson <> wrote:

    > <> wrote in message
    > news:...
    >
    >> I don't know what I'm talking about, but might wrapping some text with
    >> nested links work, one for the web page and one for the sound?

    >
    > Thanks for a sensible reply to my question which was 'how to' do it (not
    > 'should I' and 'please give your opinion on if it's a bad idea').


    Well, this is a usenet newsgroup. What this implies is
    <URL:http://groups.google.com/group/alt.html/msg/846f8ab01cc63400>.

    BTW: the nested links that are proposed, are not possible with html:

    ,------[ <URL:http://www.w3.org/TR/html401/struct/links.html#edef-A> ]
    | 12.2.2 Nested links are illegal
    |
    | Links and anchors defined by the A element must not
    | be nested; an A element must not contain any other
    | A elements.
    `------


    --
    ______PretLetters:
    | weblog | http://www.pretletters.net/weblog/weblog.html |
    | webontwerp | http://www.pretletters.net/html/webontwerp.html |
    |zweefvliegen | http://www.pretletters.net/html/vliegen.html |
    Barbara de Zoete, Mar 19, 2006
    #13
  14. Chris Ianson

    Evertjan. Guest

    Chris Ianson wrote on 19 mrt 2006 in comp.lang.javascript:

    > <> wrote in message
    > news:...
    >> Hello,
    >>
    >> I don't know what I'm talking about, but might wrapping some text
    >> with nested links work, one for the web page and one for the sound?
    >> Lacking that, you could use a Javascript onClick() event handler to
    >> redirect them after clicking the link, but you'd be dependent on them
    >> having Jscript turned on (which 95% of people do anyway).

    >
    > Thanks for a sensible reply to my question which was 'how to' do it
    > (not 'should I' and 'please give your opinion on if it's a bad idea').


    it seems a bad idea

    > Can you give an example of such code that will call a URL hyperlink
    > and play a sound when clicked please.
    >
    > Cheers!
    >
    >


    <bgsound src="silend.mid" id="song">

    <a href="http://cnn.com/" onclick="return soundlink(this);">
    Play Clip</a>

    <script >
    var where;
    function soundlink(x){
    where=x;
    document.getElementById('song').src='3secSound.mid';
    setTimeout('location.href=where.href',3000);
    return false;
    }
    </script>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 19, 2006
    #14
  15. Evertjan. wrote:

    > Chris Ianson wrote on 19 mrt 2006 in comp.lang.javascript:
    >
    >
    >><> wrote in message
    >>news:...
    >>
    >>>Hello,
    >>>
    >>>I don't know what I'm talking about, but might wrapping some text
    >>>with nested links work, one for the web page and one for the sound?
    >>>Lacking that, you could use a Javascript onClick() event handler to
    >>>redirect them after clicking the link, but you'd be dependent on them
    >>>having Jscript turned on (which 95% of people do anyway).

    >>
    >>Thanks for a sensible reply to my question which was 'how to' do it
    >>(not 'should I' and 'please give your opinion on if it's a bad idea').

    >
    >
    > it seems a bad idea
    >
    >
    >>Can you give an example of such code that will call a URL hyperlink
    >>and play a sound when clicked please.
    >>
    >>Cheers!
    >>
    >>

    >
    >
    > <bgsound src="silend.mid" id="song">
    >
    > <a href="http://cnn.com/" onclick="return soundlink(this);">
    > Play Clip</a>
    >
    > <script >
    > var where;
    > function soundlink(x){
    > where=x;
    > document.getElementById('song').src='3secSound.mid';
    > setTimeout('location.href=where.href',3000);
    > return false;
    > }
    > </script>
    >
    >

    I like that idea 'cuz it will NOT work in my browser! You will only
    annoy IE users. I also recall your cannot script it to turn on or off
    the sound like Netscape's attempt at this with EMBED, it is background
    sound *only* where you can control the looping and initial delay in
    playing when the pages loads. Also your document will not validate with
    BGSOUND element it was never part of HTML.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Mar 19, 2006
    #15
  16. Chris Ianson

    dorayme Guest

    In article <>,
    Neredbojias <> wrote:

    > > And, btw, don't stir up that "mad hatter" crowd, a few of their
    > > threads have (after a long absence) started appearing, complete
    > > with foul language, on my newsreader.

    >
    > I don't view them as a crowd, I view each as an individual with a unique
    > persona and responsible for his/her own commentary just as anyone would
    > be.


    Boji, I have reinstructed Officer Bud White. Rather than give you
    an education, I have told him to get one from you. I have told
    him to accept on trust that you will treat him fairly on his
    individual merit. In practical terms this means he will offer no
    resistance and you can beat him into a pulp.

    > Casually categorizing people into groups leads to discrimination
    > which I have found that Australians in particular are far from free of.


    Australians in particular eh? I take it that this categorization
    is not casual.

    --
    dorayme
    dorayme, Mar 19, 2006
    #16
  17. Chris Ianson

    Neredbojias Guest

    With neither quill nor qualm, dorayme quothed:

    > In article <>,
    > Neredbojias <> wrote:
    >
    > > > And, btw, don't stir up that "mad hatter" crowd, a few of their
    > > > threads have (after a long absence) started appearing, complete
    > > > with foul language, on my newsreader.

    > >
    > > I don't view them as a crowd, I view each as an individual with a unique
    > > persona and responsible for his/her own commentary just as anyone would
    > > be.

    >
    > Boji, I have reinstructed Officer Bud White. Rather than give you
    > an education, I have told him to get one from you. I have told
    > him to accept on trust that you will treat him fairly on his
    > individual merit. In practical terms this means he will offer no
    > resistance and you can beat him into a pulp.


    Nah, I wouldn't do that. Don't like to hurt people. Spanking young
    women when they need it is as far as I go.

    > > Casually categorizing people into groups leads to discrimination
    > > which I have found that Australians in particular are far from free of.

    >
    > Australians in particular eh? I take it that this categorization
    > is not casual.


    He he, apparently you "got" the didactic anecdote (-er, joke.)

    --
    Neredbojias
    Contrary to popular belief, it is believable.
    Neredbojias, Mar 19, 2006
    #17
    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. YeeCN

    How to beep or play any sound?

    YeeCN, May 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    538
    Guest
    May 13, 2004
  2. Lord2702

    How to play sound

    Lord2702, Oct 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    581
    =?Utf-8?B?c3Jpbmk=?=
    Oct 4, 2004
  3. Rick Lederman

    Play a sound

    Rick Lederman, Dec 17, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    701
    Steven Cheng[MSFT]
    Dec 20, 2004
  4. Lam

    play sound file

    Lam, Mar 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    819
    Steve C. Orr [MVP, MCSD]
    Mar 3, 2005
  5. Chris Ianson
    Replies:
    44
    Views:
    7,129
    Neredbojias
    Mar 19, 2006
Loading...

Share This Page