Solved

Change bgsound in a frame with JS?!?

Posted on 1998-11-19
5
486 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

821 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