Note: Most of the links have been removed from this page.
Although popups have been scorned because of their commercial overuse, they can play a useful role in your web sites. Similarly, tooltips provide useful information when a visitor hovers over something in a web page tagged as a tooltip.
When you complete this unit, you will:
- Understand why popups have gotten bad press.
- Know how to set up an environment for popups.
- Be able to create a popup.
- Be able to modify popup format in the popup code.
- Understand the usefulness of tooltips.
- Be able to create a tooltip.
Tooltips
Tooltips don't have the bad PR that popups have (that I know of) and are quite useful. Imagine you are a French teacher; you want students to read a short story online. You can use tooltips for the French words they are unlikely to know.
Note: This unit is based on https://www.w3schools.com/css/css_tooltip.asp
- Open up a new web page file.
- In the head area of your page, insert these CSS declarations:
<style>
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
/* Position the tooltip */
position: absolute;
z-index: 1;
}
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
- Insert this text (from Emile Zola's L'Œuvre) into the body of your page:
Claude passait devant l'Hôtel de ville, et deux heures du matin sonnaient à l'horloge, quand l'orage éclata. Il s'était oublié à rôder dans les Halles, par cette nuit brûlante de juillet, en artiste flâneur, amoureux du Paris nocturne: Brusquement, les gouttes tombèrent si larges, si drues, qu'il prit sa course, galopa dégingandé, éperdu, le long du quai de la Grève. Mais, au pont Louis-Philippe, une colère de son essoufflement l'arrêta: il trouvait imbécile cette peur de l'eau; et, dans les ténèbres épaisses, sous le cinglement de l'averse qui noyait les becs de gaz, il traversa lentement le pont, les mains ballantes.
Note: Take a look at the source of this French text to see how the accents and tildes are handled.
- Here's how to mark up a French word for a tooltip:
<span class="tooltip">l'orage<span class="tooltiptext">storm</span></span>
- Now, use tooltips to provide definitions for the following words:
l'orage | storm |
flâneur | wandering |
essoufflement | breathlessness |
dégingandé | arms dangling |
- Do a refresh to see how your page has changed, then upload this page to your home page for this course.
Note: The CSS resource on tooltips provides many variations you can use to make the tooltip look the way you want. See the link above.
Popups
Popups have a bad reputation because they have been so heavily used for advertisement. However, they can be useful for non-advertising situations. For example, as an instructor I pop up a list of student e-mail addresses so that I can send them my thoughts on their projects.
At https://www.w3schools.com/howto/howto_js_popup.asp w3schools.com provides a wealth of details on how you can finetune and enhance your popups. However, we are going to take a much simpler route!
- Open up a new web page file.
- Insert some text in the body of your page.
- Find or create something you'd like to pop up: either a text file or a graphic.
- Find a word or phrase in your text to enclose within these tags: <a href="" OnClick="hold=window.open('your_file', 'Window', 'menubar=no, scrollbars=yes, width=550, height=400, screenx=1, screeny=1'); hold.focus(); return false;"> and </a>
- Replace your_text_or_graphic with the name of your text or graphic file. Between the two parts of your popup tags, place that word or phrase that will have a link.
- Do a refresh to see if your popup works.
- You'll want to change the width and height values to fit your text or graphic. Experiment with yes/no values for menubar and scrollbar.
- Do a refresh to see how your page looks.
Practice
For this unit, create a web page with at least one tooltip and at least one popup:
- Create a basic XHTML page.
- Find some text to use for tooltips, text that could, for example, apply definitions to key terms.
- You do not need to send the standard_tooltip.js file, but you do need to copy the reference to the tooltip.js at the bottom of the page you create.
- For the popup, find some text (and image) to use in the popup. Copy the popup tagging into another web page.
- Name your HTML file with some identifying part of your name followed by _popups.html, for example, davidmc_popups.html.
- Send your web pages by e-mail attachment to your instructor at admin@mcmassociates.io. Your instructor will review, point out any problems, enabling you to revise and resend.
Return
Return to your bookmarked course main page.
Related Information
You can take tooltips and popups a lot further with these w3schools.com resources:
Information and programs provided by admin@mcmassociates.io.