ওয়েব সাইটে স্ক্রল টু টপ বাটন যুক্ত করার পদ্ধতি

ওয়েব সাইট তথ্য প্রকাশের অন্যতম জনপ্রিয় মাধ্যম। আমরা বিভিন্ন ধরণের ওয়েব সাইটের সাথে পরিচিত। কেন একটি সাইটের একটি পেজ অনেক বেশি কনটেন্ট ধরণ করতে পারে আবার কয়েকটি লাইনও থাকতে পারে। সাধারণত জনপ্রিয় ব্লগ সমূহে দেখা যায় ৩০০-৫০০ শব্দের কোন একটা পোস্টেও কয়েক শত কমেন্ট পরে,এক্ষেত্রে একজন ব্যবহারকারী পেজের শেষ প্রান্তে পৌছানোর পর আবার প্রথমে স্ক্রল করে আসতে বেশ সময় লাগে এবং বিষয়টি আমার মত অনেকের কাছেই অপছন্দনীয় । তাই সবচেয়ে ভাল সমাধান হচ্ছে একটা স্ক্রল টু টপ বাটন যুক্ত করা।

আজকের টিউটোরিয়ালে আপনাদের দেখাব কিভাবে কোন ওয়েব পেজে একটা স্ক্রল টু টপ বাটন যুক্ত করা যায়।

প্রজেক্টের বর্ণনা

একটা হলুদ রঙের পেজ তৈরি করা হবে যার হাইট যথেষ্ঠ পরিমান বড়। পেজটি স্ক্রল করে নিচের দিকে গেলে একটা কাল বাটন দেখা যাবে,যেটিতে ক্লিক করলে পেজটি এনিমেটেড হয়ে স্ক্রল করে উপরে চলে আসবে।

এক নজরে দেখে নেয়া যাক আমাদের প্রজেক্টটি।


প্রথমে ওয়েব পেজের একেবারে শেষের দিকে নিচের কোড অংশটুকু যুক্ত করুন।

<diV>

<a href=”#” class=”scrollup”>Scroll</a>

</diV>

এখন, এখান থেকে বাটনের জন্য scroll.png ইমেজটি সংগ্রহ করুন। উদাহরণ স্বরূপ ধরে নেই আপনি index.html পেজে একটা স্ক্রল টু টপ বাটন যুক্ত করবেন। তাহলে index.html যেখানে আছে সেখানে images নামে একটা ফোল্ডার খুলে ইমেজটি রাখুন।

এখন বাটনের জন্য সি এস এস স্ট্যাইল যুক্ত করে পজিশনিং করতে হবে। এর জন্য নিচের কোডটুকু কপি করে index.html এর সি এস এস ফাইলে যুক্ত করে দিন।

.scrollup{

                        width:40px;

                        height:40px;

                        text-indent:-9999px;

                        opacity:0.3;

                        position:fixed;

                        bottom:50px;

                        right:100px;

                        display:none;

                        background: url(‘images/scroll.png’) no-repeat;

                }

প্রজেক্টটি ভালভাবে খেয়াল করলে দেখবেন পেজটি স্ক্রল করে নিচের দিকে গেলে একটা কাল বাটন দেখা যাচ্ছে । যেটা নিচের দিক থেকে 50px উপরে এবং পেজের ডান দিক থেকে 100px বামে প্রদর্শন করছে, যেটা করা হয়েছে position:fixed; bottom:50px; right:100px; এর মাধ্যমে। width:40px; height:40px; এর মাধ্যমে বাটনের চওড়া এবং উচ্চতা নির্ধারণ করা হয়েছে। text-indent:-9999px; ব্যবহার করে <a href=”#” class=”scrollup”>Scroll</a> এর Scroll লেখাটিকে বাদ দেয়া হয়েছে। opacity:0.3; ব্যবহার করা হয়েছে বাটনটিকে ট্রান্সপারেন্ট করার জন্য এবং সৌন্দর্য বৃদ্ধি করার জন্য।

এখন আমরা চাচ্ছি যে বাটন টি তখনই প্রদর্শিত হবে যখন একজন ব্যবহারকারী যথেষ্ট পরিমান স্ক্রল করে নিচে যাবে।এর জন্য যে কোয়েরীর সাহায্য নিতে হবে।

$(window).scroll(function(){

        if ($(this).scrollTop() > 100) {

            $(‘.scrollup’).fadeIn();

        } else {

            $(‘.scrollup’).fadeOut();

        }

    });

এই কোডটুকু <head></head> এর মধ্যে বা </body> এর আগে <script>ট্যাগের মাধ্যমে যুক্ত করতে হবে।

এই কোডের অর্থ হচ্ছে যদি ব্যবহারকারী পেজটিকে বর্তমান অবস্থান থেকে 100px এর বেশি স্ক্রল করে তহলে ফেড ইন হবে অর্থাৎ বাটনটি দেখাবে আর 100px এর কম হলে ফেড আউট হবে।

এখন আমাদের পরবর্তী কাজ হচ্ছে যদি কেউ বাটনটিতে ক্লিক করে তাহলে এনিমেটেড হয়ে পেজটি স্ক্রল হয়ে উপরে চলে যাবে।এজন্য নিচের কোডটুকু <script>ট্যাগের মাধ্যমে যুক্ত করতে হবে।

$(‘.scrollup’).click(function(){

    $(“html, body”).animate({ scrollTop: 0 }, 600);

    return false;

    });

এই কোডের অর্থ হচ্ছে যদি কেউ বাটনটিতে ক্লিক করে তাহলে স্ক্রল করে scrollTop: 0 অর্থাৎ পেজের 0px পজিশনে চলে যাবে। 600 দ্বারা কতক্ষণ অর্থাৎ স্ক্রল হতে কত মিলিসেকেন্ড সময় নেবে তা নির্ধারণ করা হয়েছে। যদি দ্রত স্ক্রল করতে হয় তাহলে এই মান কমিয়ে দিতে হবে আর ধীরে স্কল করতে হলে এই মান বৃদ্ধি করে দেয়া যেতে পারে।

প্রয়োজনীয় সম্পূর্ণ জেকোয়েরি কোড :

<script type=”text/javascript”>

    $(document).ready(function(){

        $(window).scroll(function(){

            if ($(this).scrollTop() > 100) {

                $(‘.scrollup’).fadeIn();

            } else {

                $(‘.scrollup’).fadeOut();

            }

        });

        $(‘.scrollup’).click(function(){

            $(“html, body”).animate({ scrollTop: 0 }, 600);

            return false;

        });

    });

</script>

মোটামটি সকলেই জানেন যে জেকোয়েরি ব্যবহার করতে হলে jquery-1.7.1.min.js বা জে কোয়েরির নতুন কোন ভার্সন কল করতে হয়। এজন্য এখান থেকে jquery-1.7.1.min.js ডাউনলোড করে index.html যেখানে আছে সেখানে js নামে একটা ফোল্ডার করে তার মধ্যে রেখে <head></head> এর মধ্যে বা </body> এর আগে <script src=”js/jquery-1.7.1.min.js”></script> অনুরূপ কল করতে পারেন। অথবা  অনলাইন থেকে <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”> এর মাধ্যমেও কল করতে পারেন।

সম্পূর্ণ প্রজেক্ট:


এখান থেকে প্রজেক্ট এর সোর্স কোড ডাউনলোড করতে পারেন।

………………………………………………………………………………..

জ্ঞন বিজ্ঞানের সংস্পর্শে আলোকিত একটা সুন্দর সমৃদ্ধ পৃথিবীর প্রত্যাশায় আজ এখানেই শেষ করছি। সকলের জন্য শুভকামনা রইল।

36 thoughts on “ওয়েব সাইটে স্ক্রল টু টপ বাটন যুক্ত করার পদ্ধতি”

  1. Hands down, Apple’s software store victories by just a kilometer. It is a huge selection of all sorts regarding purposes versus a very unfortunate selection of a couple meant for Microsoft zune. Microsof company seems to have plans, specifically in all the whole world of activities, though I have no idea I’d would like to can guess to the forthcoming whether it point is critical back. The iPod can be described as significantly better decision if that’s so.

  2. Hello, Neat post. There is an issue with your website in web explorer, would test this? IE nonetheless is the marketplace chief and a huge portion of other folks will omit your wonderful writing due to this problem.

  3. Having read this I believed it was extremely enlightening. I appreciate you taking the time and effort to put this article together. I once again find myself personally spending way too much time both reading and commenting. But so what, it was still worthwhile!

  4. Currently it seems like WordPress is the best blogging platform out there right now. (from what I’ve read) Is that what you are using on your blog?|Terrific post however I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit more. Thanks!|Hi there! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!|When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!|Hello there! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a outstanding job!|Hello there! I know this is kinda off topic but I was wondering which blog platform are you using for this site? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at options for another platform. I would be great if you could point me in the direction of a good platform.|Hi there! This post could not be written any better! Reading through this post reminds me of my good old room mate! He always kept chatting about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!|Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why waste your intelligence on just posting videos to your weblog when you could be giving us something informative to read?|Today, I went to the beach with my children. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!|Yesterday, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!|I was curious if you ever considered changing the layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?|Hi, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you protect against it, any plugin or anything you can recommend? I get so much lately it’s driving me crazy so any help is very much appreciated.|This design is incredible! You definitely know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool!|I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme? Exceptional work!|Hi! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyhow, I’m definitely glad I found it and I’ll be bookmarking and checking back frequently!|Howdy! Would you mind if I share your blog with my twitter group? There’s a lot of people that I think would really enjoy your content. Please let me know. Cheers|Hey, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!|Sweet blog! I found it while browsing on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Thank you|Hello there! This is kind of off topic but I need some advice from an established blog. Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions? Cheers|Hiya! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My web site looks weird when browsing from my iphone 4. I’m trying to find a template or plugin that might be able to fix this issue. If you have any recommendations, please share. Thanks!|I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back later on. Cheers|I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to create my own blog and would like to know where u got this from. thanks|Wow! This blog looks just like my old one! It’s on a totally different topic but it has pretty much the same page layout and design. Great choice of colors!|Hi there just wanted to give you a quick heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.|Heya are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and create my own. Do you need any html coding knowledge to make your own blog? Any help would be greatly appreciated!|Whats up this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!|Hey there! I just wanted to ask if you ever have any issues with hackers? My last blog (wordpress) was hacked and I ended up losing several weeks of hard work due to no data backup. Do you have any solutions to prevent hackers?|Hey there! Do you use Twitter? I’d like to follow you if that would be okay. I’m absolutely enjoying your blog and look forward to new updates.|Hi! Do you know if they make any plugins to protect against hackers? I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?|Hey! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains. If you know of any please share. Kudos!|I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get set up? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% certain. Any tips or advice would be greatly appreciated. Appreciate it|Hmm is anyone else experiencing problems with the images on this blog loading? I’m trying to figure out if its a problem on my end or if it’s the blog. Any feedback would be greatly appreciated.|I’m not sure why but this weblog is loading very slow for me. Is anyone else having this issue or is it a issue on my end? I’ll check back later and see if the problem still exists.|Hi! I’m at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the excellent work!|Wow that was odd. I just wrote an extremely long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyhow, just wanted to say wonderful blog!|Heya outstanding blog! Does running a blog such as this require a large amount of work? I have very little expertise in coding however I was hoping to start my own blog in the near future. Anyways, if you have any suggestions or tips for new blog owners please share. I understand this is off topic however I just needed to ask. Cheers!|Hello! I realize this is somewhat off-topic however I needed to ask. Does running a well-established blog like yours take a large amount of work? I’m brand new to writing a blog however I do write in my diary everyday. I’d like to start a blog so I will be able to share my own experience and feelings online. Please let me know if you have any ideas or tips for brand new aspiring blog owners. Appreciate it!|Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.|I do not know whether it’s just me or if perhaps everybody else encountering issues with your blog. It appears as if some of the written text on your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This could be a problem with my browser because I’ve had this happen previously. Kudos|First off I would like to say superb blog! I had a quick question in which I’d like to ask if you don’t mind. I was interested to know how you center yourself and clear your head prior to writing. I’ve had a tough time clearing my thoughts in getting my thoughts out there. I truly do enjoy writing but it just seems like the first 10 to 15 minutes are usually lost just trying to figure out how to begin. Any suggestions or tips? Appreciate it!

  5. Okay you are correct, YouTube is most excellent video distribution web site, as YouTube is a lightly no much streaming time rather than other sites.

  6. Perfect writing style, Two thumbs up and up to the amazing author. This one blog goes into some details, however really what is not talked about is the quality factor. Being honest, it is not really a must, are we going to go with this path in every article/s? we should be a lot more positive about this. This isn’t a joke but in a sense it comes out to be. Let us keep this a lot more serious and to the point in the future.

  7. I know this if off topic but I’m looking into starting my own blog and was curious what all is needed to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% positive. Any tips or advice would be greatly appreciated. Cheers

  8. F*ckin’ remarkable issues here. I’m very satisfied to peer your article. Thank you a lot and i’m looking ahead to contact you. Will you please drop me a e-mail?

  9. You can definitely see your skills within the work you write. The world hopes for even more passionate writers such as you who aren’t afraid to say how they believe. Always follow your heart.

  10. I like the helpful info you provide in your articles. I will bookmark your weblog and check again here regularly. I’m quite certain I抣l learn many new stuff right here! Good luck for the next!

  11. The revolutionary Zune browser is without a doubt shockingly decent, however, not virtually typically the iPod’s. It really works nicely, although just isn’t as rapid because Internet explorer, and also has an important clunkier connect. When you from time to time anticipate when using the browser that is not a dilemma, howevere, if you plan towards look at web a lot from your very own PMP then that iPod’s more substantial screen far better browser can be necessary.

  12. Thanks for your interesting article. One other problem is that mesothelioma is generally the result of the breathing of dust from asbestos, which is a very toxic material. Its commonly found among staff in the engineering industry who may have long experience of asbestos. It’s also caused by residing in asbestos covered buildings for an extended time of time, Genetics plays a crucial role, and some individuals are more vulnerable on the risk in comparison with others.

  13. I together with my friends were found to be taking note of the nice tips and hints from your website and so then developed a terrible suspicion I never expressed respect to the web blog owner for them. My young boys happened to be absolutely joyful to study all of them and have pretty much been taking advantage of these things. Many thanks for actually being considerably kind and then for picking variety of smart subjects millions of individuals are really desirous to understand about. My honest regret for not expressing gratitude to sooner.

  14. I like the valuable info you provide in your articles. I’ll bookmark your blog and check again here frequently. I’m quite certain I will learn a lot of new stuff right here! Best of luck for the next!

  15. Thanks on your marvelous posting! I truly enjoyed reading it, you are a great author.I will remember to bookmark your blog and will eventually come back sometime soon. I want to encourage you to definitely continue your great job, have a nice holiday weekend!

  16. I just like the valuable information you supply on your articles. I will bookmark your blog and test again here regularly. I am relatively certain I will be informed many new stuff proper right here! Best of luck for the next!

  17. Great beat ! I would like to apprentice at the same time as you amend your website, how could i subscribe for a weblog site? The account aided me a acceptable deal. I have been a little bit acquainted of this your broadcast offered vibrant transparent idea

  18. Hmm it looks like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing. Do you have any points for newbie blog writers? I’d certainly appreciate it.

  19. Today, considering the fast lifestyle that everyone is having, credit cards get this amazing demand in the economy. Persons from every area are using the credit card and people who aren’t using the credit cards have made up their minds to apply for one. Thanks for discussing your ideas about credit cards.

  20. I think using a jquery file via online is not a good idea at all. Cause it may change later which may cause Ur hand made script less responsive. Even If any person use this page on offline he could not get the benifit of the script due to its absence.

    So I suggest me and other to download any online refence file (js or css), save it in any js or css folder with the main index file and tag it to the head of the htmal or php to call localy.

    Thus it will take less time and less bandwidth and be Ur own resource. Thanks..

  21. One thing is that when you’re searching for a education loan you may find that you will want a co-signer. There are many conditions where this is correct because you may find that you do not use a past credit history so the loan company will require that you’ve got someone cosign the borrowed funds for you. Good post.

  22. Thanks for the suggestions about credit repair on your site. Things i would advice people will be to give up this mentality that they may buy at this point and pay later. Like a society we tend to do this for many things. This includes getaways, furniture, plus items we really want to have. However, you have to separate your current wants from the needs. While you’re working to boost your credit score you have to make some trade-offs. For example you can shop online to economize or you can look at second hand shops instead of high-priced department stores pertaining to clothing.

  23. In these days of austerity and relative stress about incurring debt, lots of people balk contrary to the idea of using a credit card in order to make acquisition of merchandise or pay for any occasion, preferring, instead only to rely on the actual tried plus trusted way of making payment – raw cash. However, if you possess the cash available to make the purchase completely, then, paradoxically, that is the best time to use the cards for several causes.

  24. Magnificent beat ! I would like to apprentice while you amend your site, how could i subscribe for a blog site? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear concept

  25. Excellent items from you, man. I’ve be mindful your stuff previous to and you’re just too magnificent. I actually like what you’ve obtained here, really like what you’re saying and the best way through which you say it. You’re making it enjoyable and you continue to care for to keep it wise. I can not wait to read far more from you. That is actually a great site.

  26. I like the helpful info you provide in your articles. I’ll bookmark your blog and check again here frequently. I’m quite sure I’ll learn a lot of new stuff right here! Best of luck for the next!

  27. I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very web savvy so I’m not 100% sure. Any suggestions or advice would be greatly appreciated. Many thanks

  28. Hello, I discovered this page by mistake when looking on The search engines and then I came to your page. I am compelled to tell you that your site is really fantastic I definitely like your style! At this time I have a entire lot of free time to go via your webpage so I saved it. I will be back soon enough. Congrats for this fantastic site.

  29. I lately came across your website and it truly is terrific for my situation. It covers marvelous and insightful articles. I studied a good number of of them and got so a lot from them. To me, you’re putting in a superb work. Keep on! I would like to appreciate you for generating a really fantastic internet site.

Comments are closed.