javascript - scrolling script needs refresh to work properly -
i'm using following script scroll between div's:
<script type="text/javascript"> $(window).load(function(){ $(".contactlink").click(function(){ if ($("#contactform").is(":hidden")){ $("#contactform").slidedown("slow"); } else{ $("#contactform").slideup("slow"); } }); }); function closeform(){ $("#messagesent").show("slow"); settimeout('$("#messagesent").hide();$("#contactform").slideup("slow")', 2000); } $(document).ready(function() { function filterpath(string) { return string .replace(/^\//,'') .replace(/(index|default).[a-za-z]{3,4}$/,'') .replace(/\/$/,''); } $('a[href*=#]').each(function() { if ( filterpath(location.pathname) == filterpath(this.pathname) && location.hostname == this.hostname && this.hash.replace(/#/,'') ) { var $targetid = $(this.hash), $targetanchor = $('[name=' + this.hash.slice(1) +']'); var $target = $targetid.length ? $targetid : $targetanchor.length ? $targetanchor : true; if ($target) { var targetoffset = $target.offset().top - 100; $(this).click(function() { $('html, body').animate({scrolltop: targetoffset}, 1400); var d = document.createelement("div"); d.style.height = "101%"; d.style.overflow = "hidden"; document.body.appendchild(d); window.scrollto(0,scrolltom); settimeout(function() { d.parentnode.removechild(d); }, 10); return false; }); } } }); }); /*! smooth scroll - v1.4.5 - 2012-07-22 * copyright (c) 2012 karl swedberg; licensed mit, gpl */ </script>
i make target div need
<div id="about"> <a id="scrollhere"></a>
when open site first time doesn't roll there, goes wrong place in moment refresh, it's fine. have changed document.ready window.load problem still occurs. oh, , it's fine on localhost. problem? help.
Comments
Post a Comment