Forum Moderators: open
also, do you know how to make it so that when you click on an image, a tooltip of some sort pops up?
when you click on an image, a tooltip of some sort pops up?
Perhaps you mean when you "hover" over an image? Browsers are not yet consistent with that -- the W3C says a title attribute is what is correct, but you often see browsers display an alt attribute instead. Using both attributes is the safer path for now.
If you really mean "click", then you're talking about DHTML -- not really a langauge of it's own, but a combination of JavaScript and CSS. There are lots of free scripts available on the web for all kinds of DHTML effects.
But one downside for using DHTML is that it can really increase the file size of a single page. For instance, if you wanted an enlargement of an image to appear in a div that was hidden until the user clicked on it, that image would still need to download invisibly whenever the page itself downloaded -- even for visitors who never see it.
Another downside is making DHTML work well across different browsers and operating systems -- it can be a real mind bender. That's why sites with DHTML scripts exist - they have usually pre-solved the compatibility issues for you and say right up front which browsers a script is good for.
Used with caution (that is, not for extremely mission-critical purposes) DHTML can add some spice to a website.
But still, I think the easiest, surest path would be to create the HTML files that pop-up onClick and show image plus text. I do this a LOT and it's very user-friendly on most sites. Also I do not find it painful to keep track of the extra HTML files at all.
Here's how to do it in JavaScript:
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script type="text/javascript">
function createImgWin(img) {
foobar = window.open()
foobar.document.write("<html><head><title>My dynamic page</title></head><body><img src='"+img+"'><br>Here's my text. It will be displayed for every image I use.<br><br>Neat, eh? :-)</body></html>")
}
</script>
<a href="javascript:createImgWin('http://www.google.com/images/logo.gif')">Test</a>
</body>
</html>