www.webdeveloper.com
Results 1 to 5 of 5

Thread: stop a auto slide

Threaded View

  1. #1
    Join Date
    Nov 2013
    Posts
    44

    stop a auto slide

    i have a created an auto image slide gallery which i want to stop whenever i click on the "close auto " button.but cant figure out how to.so please help me out on this!!i've deleated the "next" and "previous" sections of javascript for simplification because that part works just fine.
    HTML Code:
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <style>
    #this{
    	width:500px;
    	height:100px;
    	border:1px solid blue;
    	display:none;
    }
    #this img{
    	width:100px;
    	height:100px;
    }
    #that {
    	width:300px;height:300px;
    	position:absolute;top:120px;
    	left:200px;border:1px solid black;
    }
    #that img{
    	width:300px;height:300px;
    }
    	a:hover{
    		color:red;
    	}
    </style>
    </head>
    
    <body style="position:relative;">
    <div id="this"></div>
    <div style="height:30px;width:100px;background-color:grey;float:left;position:absolute;top:0px;left:510px;" id="next"><a href="#" onClick="show();">next</a></div>
    <div style="height:30px;width:100px;background-color:grey;float:right;position:absolute;top:0px;left:0px;" id="previous"><a href="#" onClick="showBack();">previous</a></div>
    <div style="height:30px;width:100px;background-color:grey;float:left;position:absolute;top:0px;left:600px;" id="auto"><a href="#" onClick="auto();">auto</a></div>
    <div style="height:30px;width:100px;background-color:grey;float:left;position:absolute;top:50px;left:600px;" id="auto"><a href="#" onClick="close();">closeAuto</a></div>
    <div id="that"><img src="image1.jpg" /></div>
    <script>
    var i;
    	var imag = ["image1.jpg","image2.jpg","image3.jpg","image4.jpg","image5.jpg"]
    function load(){
    	var m=document.getElementById("this");
    	
    	for(i=0;i<imag.length;i++){
    		m.innerHTML += '<img src="'+imag[i]+'" id="'+i+'"  />';
    	}
    	
    }
    	</script>
    <script>load();</script>
    
    
    <script>
    a=0;
    
    function auto(){
    	
    	var m=document.getElementById("that");
    	a++;
    	if(a==imag.length){
    			m.innerHTML='<img src="'+imag[0]+'" />';
    			a=0;
    		}else{
    		m.innerHTML='<img src="'+imag[a]+'" />';
    		}
    	
    		
    		var c=setTimeout(auto,700);
    		
    }
    </script>
    <script>
    function close(){
    	clearTimeout(c);
    	var m=document.getElementById("that");
    	m.innerHTML='<img src="'+imag[a]+'" />';
    }
    </script>
    </body>
    </html>
    Last edited by alzami; 12-02-2013 at 12:26 AM. Reason: mistake

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles