By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,527 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,527 IT Pros & Developers. It's quick & easy.

Importing javascript to html file

P: 119
Hi All,

I have html page, in that i have some flash header. In that flash header i have sound on/off function. i implemented this in my html page. but i need some modification in this. now it works fine. if i switch off the flash sound sound gets switch off. But if i again refresh page or navigate to another page falsh sound gets switch on automatically.

But i dont want to switch on sound automatically.

Can any one give me idea how to overcome this problem.

i have given my script and html script below

Expand|Select|Wrap|Line Numbers
  1. <div id="container">        
  2.         <div id="logoflash">
  3.                 </div>            
  4.         <div id="load">
  5.                 </div>        
  6.                 <div class="contentbg">
  7. ---------------------------------------
  8. --------------------------
  9. --------------Some code---------------------
  10. ----------------------------------------
  12. </container>
  15. <script type="text/javascript">
  16. var flashlogo = new SWFObject("images/Flash_Logo_v1.swf", "slideshow", "394", "267", "6", "#000");
  17.     flashlogo.addParam("wmode", "transparent", "high");
  18.     flashlogo.write("logoflash");
  20.     var flashpic = new SWFObject("images/Flash_Pics_v3.swf", "slideshow2", "600", "300", "6", "#000");
  21.     flashpic.addParam("wmode", "transparent", "high");
  22.     flashpic.write("pictflash");
  24.     var sound = new SWFObject("images/ad1-sound-on.swf", "slideshow1", "27", "20", "6", "#000");
  25.     sound.addParam("wmode", "transparent", "high");
  26.     sound.write("load");
  27. </script>
This same format will repeat for all the pages which loading.

Thanks in advance,

Jul 15 '09 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 5K+
P: 5,390
in this case you could use a cookie to make the users choice persistent, or pass it everytime through an url-param, another option is to use a serverside storage (session or whatever) ... when the switch-off action is triggered do a request (probably the best is an ajax-call to avoid page-reload) and store the choosen option. when you refresh the page you will loose every runtime-made settings unless you store them somewhere before.

kind regards
Jul 15 '09 #2

P: 119
Thanks Gits,

But i m not using any Server side scripting or client side scripting for my application, even i dont have cookie or session. Is there any other way to control this flash sound other than this...

Jul 15 '09 #3

Expert Mod 15k+
P: 16,027
You are using client-side scripting (the JavaScript code which interfaces with Flash). The web is stateless by default. As gits suggested, use client-side cookies to store that the sound should be off by default. When the page loads, check for the cookie and if set, read it and set the sound accordingly.

Just a question though: do you want sound to be off for everyone by default or just for the user that decides to switch it off?
Jul 15 '09 #4

P: 119
By default the sound should be ON. if user wish he supposed to switch off the music. but till he switch ON that music. it should be in OFF state..

I think i meet your question.

Kind Regards,
Jul 16 '09 #5

Expert Mod 15k+
P: 16,027
So set a cookie when the user turns the sound off. On page load, check if this cookie is set. If it is, set the sound off. If not, you don't need to do anything as the sound is on by default.

To set, read and delete cookies, see the following links:
Jul 16 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.