Solved

Change bgsound in a frame with JS?!?

Posted on 1998-11-19
5
490 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
  • 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

861 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