?
Solved

Change bgsound in a frame with JS?!?

Posted on 1998-11-19
5
Medium Priority
?
496 Views
Last Modified: 2010-05-18
Hi,
I have a frames-based slideshow. Basically, each slide is defined in a parent array ([title], [caption], [imgURL]).  The client can scroll fwd or back through the slides using buttons in a static frame (frames[1]) via JS.
Now I have added a 4th (optional) parameter, namely [sound]. I want the bgsound (*.mid) to change programmatically, but ONLY WHEN A SLIDE CONTAINING A NEW SOUND ARGUMENT IS ENCOUNTERED.
I tried using <BODY><BGSOUND SRC ="./DUELING.MID"> in the static frames[1], but don't know how to change the SRC argument programmatically (if this is even possible).  Also, does NN still not support this tag?!?
If not, is it possible to use EMBED in either the parent or frames[1] in such a way that the SRC can be accessed and reset programmatically with JS???
0
Comment
Question by:boatful
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:boatful
ID: 1274276
Edited text of question
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 1274277
I would use the ebed command.

basically do the following:

The following is for any browser (you can eliminate the if else and only use the if part
if you are sure only 4.x browsers are viewing your site)

Create a hidden 1x1 frame called Sound that loads a blank sound.html file (you can just
have the body and html tags but basically leave it blank)

Put the following function in your control frame ...
call the function using...

playSoundfile("file location")

change attribute if you want the file to loop or not in the function itself.

function playSoundfile(soundfile) {
 //Netscape
      if (nav.indexOf("Netscape")>=0) {
            top.Sound.document.write("<HTML><HEAD></HEAD><BODY BGCOLOR=#000000><embed src="+ soundfile+" hidden=true align=baseline border=0 width=128 height=128 autostart=true autoplay=true MASTERSOUND></BODY></HTML>");
      }

//MSIE
      else if (nav.indexOf ("Microsoft")>=0) {
            window.parent.frames[1].document.write("<HTML><HEAD><BGSOUND src="+soundfile+" loop=0></BGSOUND></HEAD><BODY BGCOLOR=#000000></BODY></HTML>");
      }


hope this helped you....

CJ

0
 
LVL 6

Expert Comment

by:PBall
ID: 1274278
Hehe, don't forget to implement a stop function.
continously looping midi can be ... annoying :).

And actually <EMBED> will work with both Netscape and IE, so you won't need the <BGSOUND> at all.
0
 

Author Comment

by:boatful
ID: 1274279
Thanks for helping, guys.  I was able to implement CJ's answer satisfactorily, and would give the points if you post as an answer "See comment above".
As for looping, I will probably just set loop to 1.  What I wish is that there was a "fade" property, for a smooth transition when a second embed call interrupts a song that's still playing.
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 400 total points
ID: 1274280
Here is my answer

I would use the ebed command.

      basically do the following:

      The following is for any browser (you can eliminate the if else and only use the if part
      if you are sure only 4.x browsers are viewing your site)

      Create a hidden 1x1 frame called Sound that loads a blank sound.html file (you can just
      have the body and html tags but basically leave it blank)

      Put the following function in your control frame ...
      call the function using...

      playSoundfile("file location")

      change attribute if you want the file to loop or not in the function itself.

      function playSoundfile(soundfile) {
       //Netscape
      if (nav.indexOf("Netscape")>=0) {
      top.Sound.document.write("<HTML><HEAD></HEAD><BODY BGCOLOR=#000000><embed
      src="+ soundfile+" hidden=true align=baseline border=0 width=128 height=128 autostart=true
      autoplay=true MASTERSOUND></BODY></HTML>");
      }

      //MSIE
      else if (nav.indexOf ("Microsoft")>=0) {
      window.parent.frames[1].document.write("<HTML><HEAD><BGSOUND src="+soundfile+"
      loop=0></BGSOUND></HEAD><BODY BGCOLOR=#000000></BODY></HTML>");
      }


      hope this helped you....

      CJ
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question