PDA

View Full Version : [DHTML]A Simple Link Description Script



Master_script_maker
06-10-2007, 02:26 PM
1) CODE TITLE: A Simple Link Description Script

2) AUTHOR NAME/NOTES: Master_script_maker

3) DESCRIPTION:
Allows people to see a description of where the link takes you to.

4) URL TO CODE: http://linkdescription.freehostia.com

or, ATTACHED BELOW (see #3 in guidelines below):

thetestingsite
06-10-2007, 02:27 PM
The site you linked to is just the server directory listing for your "root directory" and there are no files in it. Please either post the code, or make the link a valid one.

Master_script_maker
06-10-2007, 04:36 PM
The site you linked to is just the server directory listing for your "root directory" and there are no files in it. Please either post the code, or make the link a valid one.

Thank you. Something was messed up but i fixed it now.

thetestingsite
06-10-2007, 04:39 PM
Looking at the code, it seems simple enough to integrate into your own applications. Not sure if DD will post it on the site, but it seems that even a simple beginner to Javascript would be able to use and customize it.

Twey
06-10-2007, 05:27 PM
<script>The type attribute is required.
<!--This is no longer necessary, and will break your script in XHTML pages.
document.getElementById(number).innerHTML = " " + text;innerHTML is non-standard and has several practical issues.
<a href="yoursite" onmouseover="display('the text to display','1')" onmouseout="undo('1')">yoursite</a><font color="black" id='1'> </font>The <font> tag is not valid HTML Strict. IDs may not start with a number.

Wouldn't it make more sense to use the same element for all links? You're never going to have more than one description up at a time, after all. You could make it less obtrusive, too:
<script type="text/javascript">
onload = function() {
var m, i, a, as,
mo = function() {
document.getElementById("descr").firstChild.nodeValue = "";
};

if(!(m = document.getElementById("descr"))
(m = document.body.appendChild(
document.createElement("p")
)).id = "descr";

if(!m.firstChild)
m.appendChild(document.createTextNode(""));

for(i = 0, as = document.links, a = as[0]; i < a.length; a = as[++i])
if(m = a.className.match(/describe\(([^\)]+)\)/) {
a.onmouseover = (function(d) {
return function() {
document.getElementById("descr").firstChild.nodeValue = d;
};
})(m[1]);
a.onmouseout = mo;
}
};
</script>Then:
<span id="descr"></span>And:
<a href="somepage.html" class="describe(Some page or other.)">Some Page</a>