Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Scrolls to last "scroll position". Uses localStorage.
<a href="javascript:(function(){var v=&quot;1.3.2&quot;;if(window.jQuery===undefined||window.jQuery.fn.jquery&lt;v){var done=false;var script=document.createElement(&quot;script&quot;);script.src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/&quot;+v+&quot;/jquery.min.js&quot;;script.onload=script.onreadystatechange=function(){if(!done&amp;&amp;(!this.readyState||this.readyState==&quot;loaded&quot;||this.readyState==&quot;complete&quot;)){done=true;initMyBookmarklet();}};document.getElementsByTagName(&quot;head&quot;)[0].appendChild(script);}else{initMyBookmarklet();}function initMyBookmarklet(){(window.myBookmarklet=function(){jQuery(&quot;.nextProda&quot;).live(&quot;click&quot;,function(){if(typeof(localStorage)=='undefined'){alert('Ваш браузер не поддерживает localStorage()');}else{jQuery(document).scrollTop(localStorage.getItem('scroll'+encodeURIComponent(window.location.pathname)));}return false;});jQuery(&quot;body&quot;).append('&lt;a href=&quot;#&quot; class=&quot;nextProda&quot; style=&quot;background-color:rgb(190,111,98);display:block;left:0;position:fixed;top:50%;width:90px;padding:8px;text-align:center;color:#fff;border-radius:0 10px 10px 0&quot;&gt;Продолжить чтение&lt;/a&gt;');jQuery(window).scroll(function(){if(typeof(localStorage)!='undefined'){if(jQuery(&quot;.nextProda&quot;).length&gt;0){jQuery(&quot;.nextProda&quot;).width('20px').html('Zz..').css('font-size','10px');}try{localStorage.setItem('scroll'+encodeURIComponent(window.location.pathname),jQuery(document).scrollTop());}catch(e){if(e==QUOTA_EXCEEDED_ERR){}}}});})();}})();" id="codeOut">Продолжить чтение</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment