Solved

Change bgsound in a frame with JS?!?

Posted on 1998-11-19
5
482 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
Comment Utility
Edited text of question
0
 
LVL 19

Expert Comment

by:cheekycj
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now