Results 1 to 7 of 7

Thread: help with two popup and sound

  1. #1
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post help with two popup and sound

    Hi all, first timer on here looking for some advice, help and whatever else you might want to throw my way. but please be gentle.

    Question is, I have page that contains a few links on it (all internal) and I'm already using a javascript to launch a pop up window when user clicks on link. somehow i ended up with all the links being highlighted as well but i think thats due to a menu im using, i dont know, but i like it.everything is great but i was thinking adding a sound to that same link. that onmousever script would be perfect but i dont know hot to add that to existing. any ideas?

    this is how im displaying my link.

    <li><a href=javascriptopcontact('1.htm')><font face="Verdana" size="2">
    Installations</font></a>
    <li><a href=javascriptopcontact('2.htm')><font face="Verdana" size="2">
    Repair</font></a>


    thanks in advance..

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What do you want the sound to do? Do you want it to play when the link is clicked (sound effect) or at some other time? Or, do you want a long sound file to commence playing?

    In any case, using the javascript: convention is a poor choice, this is better:

    Code:
    <a href="1.htm" onclick="popcontact(this.href);return false;"><font face="Verdana" size="2">
    Installations</font></a>
    Once you have it broken out that way, you can add to the onclick event:

    Code:
    <a href="1.htm" onclick="popcontact(this.href);make_noise();return false;"><font face="Verdana" size="2">
    Installations</font></a>
    Or, add a different event:

    Code:
    <a href="1.htm" onclick="popcontact(this.href);return false;" onmouseover="make_noise();"><font face="Verdana" size="2">
    Installations</font></a>
    Notes: make_noise(); is just a name I made up. If you have an actual function to run, use its name.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks jscheuer1.

    to answer your question on what i want it to do. i want to play a slimmed down version of a click sound, nothing fancy or big just a little click effect so that user knows (if the highlight isnt enough) its a link. dont want any song, chorus or background music just a simple click when mouse moves over it and thats it.

    if you dont mind me asking why is the javasript a bad idea? i thought that was the only way to do a pop up window but i guess not.

    anyway thanks for the reply and i'll see what happens with using your code. thanks again.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by mikez View Post
    thanks jscheuer1.

    if you dont mind me asking why is the javasript a bad idea? i thought that was the only way to do a pop up window but i guess not.
    It can lead to all sorts of problems. In many IE versions, it institutes page unload. This can mess up many things on the page where these types of links are, if (as in this case) clicking the link doesn't actually unload the page.

    It makes it tougher to combine events.

    That's the worst that I am aware of but, as a courtesy to non-javascript enabled browsers, there should generally be a real href on an anchor link. What this href is should be some sort of non-javascript alternative to what would otherwise (if different) happen when clicking the link in a javascript-enabled browser. Having a real link here also helps index your site. If no link is truly desired, then an anchor tag is inappropriate and javascript events can be attached to another element.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Sep 2007
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hey There,

    I've actually got a similar problem, but my link is calling another application instead of another browser window. What I want is to make it play the sound file upon clicking the link as well as open up the other window.

    I'm currently using this syntax:

    <a href="telnet://berdusk.com:2223" onclick="playsound('ding2.wav');"><img src="BerduskBanner3.jpg" width="500" height="125" border="0" alt="Connect to Berdusk"></a>
    If I change to onclick="playsound('ding2.wav');return false;" I am able to get my browser to play the sound file, but it doesn't open up Telnet.

    If I change to onclick="playsound('ding2.wav');return true;" I am able to get my browser to open Telnet, but it won't play the sound file.

    Currently, without using either one, I am sometimes able to catch the very beginning of the sound file before it cuts off and opens the application.

    Any suggestions would be helpful. Thank you.

    -Daniel

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You've narrowed down the problem well.

    Seems like the problem is fairly simple. Once focus has shifted to the other app, the sound is no longer heard. In fact, I expect it DOES play, but just isn't heard when the window isn't focused.

    That means you will need to decide-- do you want the sound to play or the telnet window to be focused?

    I think the options here are pretty simple, though nothing jumps out as great.
    1. Skip the sound.
    2. Keep focus on the current window, using window.focus(). I think this should work, but it would place telnet behind the current window, then.
    3. playsound(), until it's done, and THEN open the telnet window. Probably the best option, but this will delay the telnet page loading for the length of the audio, including loading.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Sep 2007
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Okay. I kind of figured it had something to do with the browser no longer being the active window from the behavior above, but I didn't want to speak out of turn.

    What changes would I need to make to the syntax above to make it so that it didn't load Telnet until after the sound file had played? Thanks for the help.

    -Daniel
    P.S. Thanks for the fast response. ^_^

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •