Back to top button
2 posters
Page 1 of 1
Back to top button
Hello ,
I'm trying to add a "Back to top" button on my forum however the code doesn't work , can anyone help me out with this?
The code I'm using is from http://davidwalsh.name/jquery-top-link
The error I'm getting is
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'scrollTo' 30305.js:1
(anonymous function) 30305.js:1
f.event.dispatch jquery.min.js:3
f.event.add.h.handle.i
I'm trying to add a "Back to top" button on my forum however the code doesn't work , can anyone help me out with this?
The code I'm using is from http://davidwalsh.name/jquery-top-link
The error I'm getting is
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'scrollTo' 30305.js:1
(anonymous function) 30305.js:1
f.event.dispatch jquery.min.js:3
f.event.add.h.handle.i
Re: Back to top button
I put the javascript in the Javascript codes management (checked it in all pages) , and css in the CSS Stylesheet
Re: Back to top button
- Code:
jQuery.fn.topLink = function(settings) {
settings = jQuery.extend({
min: 1,
fadeSpeed: 200
}, settings);
return this.each(function() {
//listen for scroll
var el = $(this);
el.hide(); //in case the user forgot
$(window).scroll(function() {
if($(window).scrollTop() >= settings.min)
{
el.fadeIn(settings.fadeSpeed);
}
else
{
el.fadeOut(settings.fadeSpeed);
}
});
});
};
//usage w/ smoothscroll
$(document).ready(function() {
//set the link
$('#top-link').topLink({
min: 400,
fadeSpeed: 500
});
//smoothscroll
$('#top-link').click(function(e) {
e.preventDefault();
$.scrollTo(0,300);
});
});
The problem must be smoothscroll effect because without it the code works.
edit: nvm about this code , found a working one at http://gazpo.com/2012/02/scrolltop/
you can lock the topic
Re: Back to top button
Topic Solved & Locked |
Sanket- ForumGuru
- Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai
Similar topics
» "Back to Top" Button too small and too near "Report" button.
» Go Back Button
» Problem with back button
» Back To Top Button/Link
» (REQUEST)Link Back to us button
» Go Back Button
» Problem with back button
» Back To Top Button/Link
» (REQUEST)Link Back to us button
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum