From our sponsor: Meco is a distraction-free space for reading and discovering newsletters, separate from the inbox.
Today we want to share a little script with you that allows to create a tour on a website with jQuery. This can be very useful if you want to explain your users the functioning of your web application in an interactive way.
You might have noticed that Facebook used something like this to explain the new features of the profile.
The idea is to add a certain class to elements that you want to guide the user through and explain what they do. We will use a little tooltip to show what that tour point is about, and a navigation will allow the user to go back and forth, to end the tour or to restart it.
Another option that you can use is autoplay which will allow the user to simply sit back and watch every step without having to click on the next button. You can see this in action here
To use this, you simply have to add a certain class to an element that you want to describe in the walk-through. We will be using “tour_1”, “tour_2” and so on:
<div class="box left"> <h2 class="tour_1">Create a tour</h2> <p>Far far away, behind the word mountains, ...</p> </div>
Now, we will configure the steps in a JSON object. The following parameters can be set:
- name: the class given to the element where you want the tooltip to appear
- bgcolor: the background color of the tooltip
- color: the color of the tooltip text
- text: the text inside of the tooltip
- time: if automatic tour, then this is the time in ms for this step
- position: the position of the tip
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
So, for our first tour step we would add something this:
var config = [ { "name" : "tour_1", "bgcolor" : "black", "color" : "white", "position" : "TL", "text" : "Some text here", "time" : 5000 },... ]
By default, we will have autoplay disabled. If you would like the walk-trough to be automatic, then just change the autoplay variable to true (line 158).
For the position of the tooltip we have the following possible values:
- TL: top left
- TR: top right
- BL: bottom left
- BR: bottom right
- LT: left top
- LB: left bottom
- RT: right top
- RB: right bottom
- T: top
- R: right
- B: bottom
- L: left
The last four ones are all centered.
You can adapt the style of the navigation buttons in the jquerytour.css.
We hope you find this script useful! Enjoy!
Awesome demo, the code its just beautiful. Thanks for sharing!
Wow…nice idea. U always make jquery awesome…
No need to say any more, awesome. I’m waiting for new Codrops’s posts everyday via email scribe.
Thank you!
Nice!
Awesome! π
wow.. awesome
Yet another great tutorial/script. Thanks for submitting to the community.
What a great idea and it’s extremely easy to implement.
When I clicked “Next” the first time, I didn’t notice that it turned into a “Previous” button, and so I clicked it over and over again and all it did was toggle between the two.
Thanks for sharing all of this work!
Great ..
I looking for this
Wow ! Amazing script… Thx Codrops, you’re da best !
Super! Thx.
Great job !
Just a probleme with Internet Explorer. the tooltip_arrow are not “leftright.png” and “topbottom.png”
In the Demo, when go through the whole tour, then you click to Restart the tour, you don’t get a “Next” button, so you can’t go anywhere after that other than End Tour. (IE8, if that matters)
Also, I’d love to see an auto-play example as part of the demo, too.
Hello tom,
thank you, it was a bug. It’s now fixed and the file is updated. If you want to see an autoplay example : http://tympanus.net/Development/WebsiteTour/indexAuto.html
Cheers, ML
This is awesome for some Chrome Web Apps I’m working on.
And maybe many other sites … cool!
Brilliant! I definitely can use this in the new year, thank you.
I agree with Tom, the previous/next buttons should jut become inactive, not moved around.
new breakthroughs, ck ck ck thanks
Wow this is pretty cool and I think this will be very useful for me… Thanks for sharing all those beautiful tuts/scripts/ideas π
great explanation thanks for sharing this it is more helpful to me keep posting
Would be nicer still, if the div element it focused on when stepping thru the tour, remained with different opacity.. would give a real focus on this element feel.
Great tut tho. Thanks
Just another suggestion.
We have say this_page.html and the tour is at this_page_tour.html . Is there a way , that when tour is complete we can auto redirect to this_page.html ?
Regards
Yes that is possible @Steve π
I am playin’ around with the “plugin” and I was thinking of using the jQuery Tools Exposure plugin to “highlight” the div element that is getting focused.
—
I wish the whole CoDrops team a merry xmas … and a peaceful time… ofcourse all others here, too π
Hi Michael, yeah that would be cool. Merry Xmas
can i call you (jMary Lou) ? you’re the jInspirations lady. oh my god! she is awesome.
Thank you dantario! π Merry Christmas to all of you! Cheers from the team, ML
Hi ML, noted in your js, this:
$tourcontrols += ‘<a>Restart the tour’;
Shuldnt the closing span tag be a closing a tag
Hello Steve,
that’s true, instead of the span after “Restart the tour”, it should be an ending “a”.
Thanks,
Cheers, ML
Hi,
i added a new case in the position-switch:
default:
properties = {
‘left’ : ‘50%’,
‘top’ : ‘50%’,
‘margin-top’: ( $tooltip.height ( ) / 2 ) * (-1),
‘margin-left’: ( $tooltip.width ( ) / 2 ) * (-1),
};
break;
so if you leave the position blank, set it to false or do anything else, the tooltip would be placed in the centre of the screen…. π
nice work btw. i’ll do some additional work to make a real plugin out of it… π if it’s okay to you.
hi, sorry: me again π
i forgotten to say i’ve changed the line:
var $elem = $(step_config.name);
to:
var elSelector = step_config.name || ‘#tour_overlay’;
var $elem = $(elSelector);
if you want to place the tooltip in the centre of the screen you have to set “name” to false, so the tooltip will be bound to “#tour_overlay” by default.
thx.
Hi,
This doesnt seem to work in jQuery 1.3.2 – just wondering what’s causing it to fail in this lib ?
Thanks
Hi,
thank you for this great plugin!
I only have one question: Is it possible to open the tour only when you have clicked on a button on the page? And when yes, how?
thx
Very Nice…thanx
This is great! I like the interactive jquery tour and will be very useful in directing the user on the elements of a website. Good for instruction.
Is this tool also free for commercial use?
is there any way to call an external json for the tour?
Hi! Would You like to help me? How I can make to start this plagin only when definite variable have a definite value. Example, $first_enter = 1.
Great Thanks
Oh very cool tut.
I will definately implement it on my site.
Is it possible to highlight a whole div with this or it only suppors the box appearing on top of the defined class?
regards
Nick
I want to use this beautiful effect on my website. It works on Chrome, Safari & Opera but IE8 doesn’t show the arrows of the tooltips ?
Is anyone knows why ?
Thanks
Ok, Mary Lou, you are a “Beast”! Who are you, where do you come from and are there more like you there? Seriously, I’ve been browsing this site for a few minutes now and everything thats got your name on it has been worth checking out. Remarkable content, congrats. (ps: send me a note, lets talk. (biz))
*like* π
Just perfect. :o)
I transformed this into a jQuery plugin – check it out: http://blog.routydevelopment.com/?p=233
Mary lou,
Exactly what I was looking for!!!
This is a great tutorial ! Thanks for sharing.Keep it up!
Simplemente genial, este blog es la onda π
Just great, this blog is awesome
Hi from Mexico
This is just what I was looking for. Really nice!
Thanks for sharing Mary Lou.
That’s amazing plugin!! Just saw it in TM blog! Very useful, a great “new” way to present tours (FB like).
thanks!
great script, however, it conflicts with jquery.svgdom.js, a part of the jQuery SVG plugin from http://keith-wood.name. If jquery.svgdom.js is included in the web page which triggers the Tour, there is an error.
Hi–
Have you released this under a license like BSD? I would like to use it in a project.
Hi Pete,
please use it as you wish! Cheers, ML
hi!
well done is clean and easy to setup.
i have a question how could you initiate the tour from a button or a link instead of auto loading?
Hi!
Talking about you in “The Inspector”: http://www.retro-bottega.com/2011/04/16/the-inspector-01-website-tour-con-jquery/
Cheers π
Nice, THX π
Used & Tweaked @ http://www.pixfx.at
Greetz LosMikEos!
Cheers for this “Web site tour” ! I used it for my web site and it works great ! great article !