Run Javascript code with ID and Hash -


what can run code hash , id? create onmousedown want run code has , id, like: #content + id="content"

html:

<div class="buttons">   <a href="#" onclick="return false" onmousedown="autoscroll('content')"> go content  page</a>   <a href="#" onclick="return false" onmousedown="autoscroll('contact')"> go contact  page</a>   <a href="#" onclick="return false" onmousedown="autoscroll('bottom')"> go bottom  page</a> </div> <div id="content" class="content"></div> <div id="contact" class="contact"></div> <div id="bottom" class="bottom"></div> 

javascript:

var scrolly = 0; var distance = 40; var speed = 20;  function autoscroll(el) {   var currenty = window.pageyoffset;   var targety = document.getelementbyid(el).offsettop;   var bodyheight = document.body.offsetheight;   var ypos = currenty + window.innerheight;   var animator = settimeout('autoscroll(\'' + el + '\')', speed)   if (ypos > bodyheight) {     cleartimeout(animator);   } else {      if (currenty < targety - distance) {       scrolly = currenty + distance;       window.scroll(0, scrolly);     } else {       cleartimeout(animator);     }    } } 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -