Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change bgsound in a frame with JS?!?

Posted on 1998-11-19
5
Medium Priority
?
498 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

610 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