48 users online (0 members and 48 guests)  


  Results 1 to 6 of 6

Related

  1. Hit Counter malfunction!!    Forum: PHP Forum
    Replies: 0
  2. looking for a counter    Forum: Website Scripts Forum
    Replies: 3
  3. looking for a counter    Forum: Introduce Yourself
    Replies: 1
  4. Counter!!!!!    Forum: Website Scripts Forum
    Replies: 3
  5. hit counter    Forum: HTML Forum
    Replies: 5
  1. #1
    Ylvur's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    3

    Question Music and counter at the same time, possible?

    Hi all.

    Hope someone can help me. Im having trouble when Im
    trying to start two functions at the same time.

    What I want is this... when you click on an image it shall
    start both play() and Initialize_Timer()

    One function plays a short intro and the other one
    starts a to count down from 500 to zero.

    They work just fine if I just do one, but when I want them
    to occur at the same time only the counter starts. And the
    music disappers.

    How can I correct this, is it possible to start both at the same time?

    Greatful for help.


    ************** here comes the code **************

    HTML Code:
    <html>
    <head>
    
    <script language = "JavaScript">
    <!--
    
    var secs
    var timerID = null
    var timerRunning = false
    var delay = 10
    
    function Initialize_Timer(){
    		document.all['counter'].style.visibility = 'visible';
        secs = 500
        Stop_Timer()
        Start_Timer()
    		}
    
    function Stop_Timer(){
        if(timerRunning)
            clearTimeout(timerID)		
        timerRunning = false
    		}
    
    function Start_Timer(){
        if (secs==0)
        {
    				document.all['counter'].innerHTML=0;
            Stop_Timer()
    				document.all['counter'].style.visibility = 'hidden';
            alert("Times up.")
        }
        else
        {
    				write_layer('counter',secs);
            secs = secs - 10
            timerRunning = true
            timerID = self.setTimeout("Start_Timer()", delay)
        }
    }
    
    
    function play(){
    strang="<embed id=player src='C:/Inetpub/wwwroot/music/pics/lt4.mp3' autostart='true' hidden='true' loop='0' width=0 height=0></embed>";
    write_layer('buttons',strang);
    document.all['buttons'].style.visibility = 'visible';
    }
    
    function write_layer(layername,str){
    document.all['counter'].innerHTML = str
    }
    
    //-->
    </SCRIPT>
    
    <style type="text/css">
    	#counter {position: absolute;left: 65px;top: 5px;z-index:1;padding: 10px;border: none;visibility: visible;}
    	#buttons {position: absolute;left: 50px;top: 80px;z-index:2;padding: 10px;border: none;visibility: hidden;}
    	.timer{font-family:betsy flanagan;font-size:40pt;color:#2869A2;font-weight:bold;}
    	A {text-decoration:none}
    	A:link {color:#2869A2}
    	A:visited {color:#2869A2}
    	A:active {color:#2869A2}
    	A:hover  {color:#2869A2}
    </style>
    
    </head>
    
    <body>
    
    <a href="javascript:play();Initialize_Timer();"><img src="pics/play.gif" alt="" width="39" height="34" border="0"></a>
    
    <div id="counter" class="timer"></div>	
    <div id="buttons">
    	<table cellspacing="2" cellpadding="2" border="0">
    	<tr>
    	    <td><a href="#"><img src="pics/a.gif" alt="" width="39" height="34" border="0"></a></td>
    	    <td><a href="#"><img src="pics/b.gif" alt="" width="39" height="34" border="0"></a></td>
    	    <td><a href="#"><img src="pics/c.gif" alt="" width="39" height="34" border="0"></a></td>
    	</tr>
    	<tr>
    	    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    	    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    	    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    	</tr>
    	</table>
    </div>
    
    </body>
    </html>
    *********************************************

    *edit to remove smilies
    Last edited by QuietDean; 10-31-2003 at 02:41 PM.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi There, welcome to the forums.

    Its only a hunch, but try amending

    HTML Code:
    <a href="java script:play();Initialize_Timer();">
    to

    HTML Code:
    <a href="javascript:void(0);" onClick="play();Initialize_Timer();">
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Ylvur's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    3

    Didnt work...

    Hi there.

    Thanx for the tip but unfortunaly it didnt work - same
    thing... countdown works fine but still no music.

    If i try to move the play function to <body onload=.... > to test whats happening the song plays until I click the other
    button then it stops and starts counting, any more ideas?

    //confused

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hmm. I cannot see any obvious clashes. Try swapping functions around?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    Ylvur's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Posts
    3
    Yup, but that didnt work either... still the same result.

    //Y

  6. #6
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732
    Hi there Ylvur,

    I have finally got this to work
    When checking it out I found that the 'player'
    would not work in Netscape so I have changed that.
    Here is the modified code...
    Code:
    <html>
    <head>
    
    <script type="text/javascript">
    <!--
    var secs
    var timerID = null;
    var timerRunning = false;
    var delay = 50;
    
    function Initialize_Timer()
    {
    document.getElementById("counter").style.visibility = 'visible';
    secs = 500;
    Stop_Timer();
    Start_Timer();
    }
    
    function Stop_Timer()
    {
    if(timerRunning)
    {
    clearTimeout(timerID);		
    timerRunning = false;
    }
    }
    
    function Start_Timer()
    {
    if (secs==0)
    {
    document.getElementById("counter").innerHTML=0;
    Stop_Timer();
    play();
    document.getElementById("counter").style.visibility = 'hidden';
    }
    else
    {
    write_layer('counter',secs);
    secs = secs - 10;
    timerRunning = true;
    timerID = self.setTimeout("Start_Timer()", delay);
    }
    }
    
    function play()
    {
    strang="<object classid='clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6' codeBase='#Version=7,0,0,1954'width='0'height='0'><param name='url'value='C:/Inetpub/wwwroot/music/pics/lt4.mp3'><param name='autostart'value='true'><param name='playcount'value='1'></object>";
    write_layer('buttons',strang);
    document.getElementById("buttons").style.visibility = 'visible';
    }
    function write_layer(layername,str)
    {
    document.getElementById("counter").innerHTML = str;
    }
    //-->
    </script>
    
    <style type="text/css">
    #counter {position: absolute;left: 65px;top: 5px;z-index:1;padding: 10px;border: none;visibility: visible;}
    #buttons {position: absolute;left: 50px;top: 80px;z-index:2;padding: 10px;border: none;visibility: hidden;}
    .timer{font-family:betsy flanagan;font-size:40pt;color:#2869A2;font-weight:bold;}
    a {text-decoration:none}
    a:link {color:#2869a2}
    a:visited {color:#2869a2}
    a:active {color:#2869a2}
    a:hover  {color:#2869a2}
    </style>
    
    </head>
    
    <body>
    
    <a href="#"onclick="Initialize_Timer();"><img src="pics/play.gif" alt="" width="39" height="34" border="0"></a>
    
    <div id="counter" class="timer"></div>	
    <div id="buttons">
    <table cellspacing="2" cellpadding="2" border="0">
    <tr>
    <td><a href="#"><img src="pics/a.gif" alt="" width="39" height="34" border="0"></a></td>
    <td><a href="#"><img src="pics/b.gif" alt="" width="39" height="34" border="0"></a></td>
    <td><a href="#"><img src="pics/c.gif" alt="" width="39" height="34" border="0"></a></td>
    </tr>
    <tr>
    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    <td><a href="#"><img src="pics/t.gif" alt="" width="39" height="34" border="0"></a></td>
    </tr>
    </table>
    </div>
    
    </body>
    </html>
    This has been tested in IE 6.0 and Netscape 7.1
    (the only problem is that the countdown in Netscape
    is not as smooth as in IE.)

    cthead



Tags for this Thread