vchris Posted March 7, 2006 Share Posted March 7, 2006 I have a word that will repeat itself a couple times and I want that on mouse hover (title) it display the definition. I think the best way is with JS unless you have a better idea.How would I do that? JS:if(document.getElementById.id=='deprecated'){ document.deprecated.title='Deprecated definition';}HTML:<span id="deprecated">Deprecated.</span> Link to comment Share on other sites More sharing options...
scott100 Posted March 7, 2006 Share Posted March 7, 2006 (edited) Why not just use the html title attribute:<p>I am <span style="text-decoration:underline" title="Depricated: blah blah blah">depricated</span> in a paragraph</p> Edited March 7, 2006 by scott100 Link to comment Share on other sites More sharing options...
vchris Posted March 7, 2006 Author Share Posted March 7, 2006 Because the text will be a definition which is a long sentence which I will repeat for every instance of the word deprecated. If ever I want to change something in the sentence or just remove it, it's a lot easier with JS I believe. Of course I could always do search and replace to modify the sentence. Link to comment Share on other sites More sharing options...
sbrownii Posted March 7, 2006 Share Posted March 7, 2006 you can only use a particular id once in an html document. Maybe you could use a class named "deprecated" instead of an id. Then you could loop through the elements of the document looking for matches to that class.if you want to just use the mouseover even like you were trying.. change it to thisjavascript function setTitle(element){ element.title="A deprecated element or attribute is one that has been outdated";} html The applet element was <span class="deprecated" onmouseover="setTitle(this)" title="">deprecated</span> in HTML 4.01. You could change the function to accept additional parameters so that it can work for more than one term. You could store definitions in an 2 dimensional array first column would be the term, second the definition... just make sure you change the function calls to match...if you use server-side scripting... you could just store the definition in a variable and print that variable into the title attribute of all the elements you need it in. If you need to make a change, just change the value of the variable.you could use style definitions to set the cursor, font color, background color, text-decoration, etc... to let the user know there is something different about that text...An alternative to using the mouseover would be to have the user click and get a popup that displays the definition in an easier to view format... Link to comment Share on other sites More sharing options...
vchris Posted March 8, 2006 Author Share Posted March 8, 2006 I will be using PHP for this project so I think the best way is with the variable (simple and easy). I'm just trying to create a template right now.It's awesome! it's a web programming site Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now