Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello friends,
First sorry if I ask silly question. I am developing HTML5 based application in which I have used iFrame to play sound in another page. Now I want to set attribute of Iframes. how to do so


default.html

<iframe src="bhMusic.html" style="display:none;"></iframe>

In bhMusic.html I am playing sound. Now I want to stop that music. How would I do that. Please help me.

Thank you in adnvance


Updated Question

First thank you all for showing interest. Okay here is my code HTML page where iFrame is used to play sound

default.html
HTML
<html>
    <head>
      <link href="/css/default.css" rel="stylesheet" /> 
      <script src="/js/default.js"></script>
    </head>
 
   <body>
        <iframe src="bhMusic.html" style="display:none;"></iframe>
   </body>
</html>


Note: display:none

bhMusic.html

HTML
<html>
    <head>
    </head>
 
    <body>
        <audio src="/sounds/preview-scrap.mp3" controls="controls" autoplay="" loop="" />
    </body>
</html>


I am showing default.html where Iframe is used. and I dont want to display that iframe. Now if I want to stop playing sound. what should I do?

Thank you.
Posted
Updated 5-Jun-13 20:16pm
v2
Comments
lotussilva 5-Jun-13 9:25am    
I want to help you but I'm going to need a bit more code than this. The iframe is not what is making your sound play or stop playing. It's your script (JS, JQuery, etc). I have several ideas on how to get it done but if you insist on the iframe method then I need to see all code related to the sound playing action.
NachiketM 6-Jun-13 1:41am    
Yes sir, I am posting it below.

If you are loading it in iFrame, then the page is there. No need to do anything on the iFrame.

You need to do some functionality in html page itself, so that you can stop the sound.
Show some button, which will stop the music. And you can see that in the iFrame itself, as it is added to html page.

The concept is the iFrame will show each and every content of the source file, in your case that is the html file.

So, if you will add the functionality in html, then that will definitely show inside the iFrame, as it is just a container or window which is showing the page.

Hope you understand... :)
 
Share this answer
 
First thank you all for showing interest. Okay here is my code

HTML page where iFrame is used to play sound
default.html

HTML
<html>
    <head>
      <link href="/css/default.css" rel="stylesheet" /> 
      <script src="/js/default.js"></script>
    </head>

   <body>
        <iframe src="bhMusic.html" style="display:none;"></iframe>
   </body>
</html>

Note: display:none


bhMusic.html
HTML
<html>
    <head>
    </head>

    <body>
        <audio src="/sounds/preview-scrap.mp3" controls="controls" autoplay="" loop="" />
    </body>
</html>



I am showing default.html where Iframe is used. and I dont want to display that iframe. Now if I want to stop playing sound. what should I do?

Thank you.
 
Share this answer
 
Comments
Mohibur Rashid 6-Jun-13 1:59am    
don't add as an answer.............
NachiketM 6-Jun-13 2:00am    
Sorry

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900