Jump to content

Disable Alt/Title Text


Recommended Posts

Hi All On my site I have images that are links to pop-up functions. The javascript pop-up script uses the Title attribute of the image as the "Title" displayed in the pop-up. These images also have javascript tool-tips on the mouseover events. I would like to disable the "default" mouseover Alt/Title text messages for these images, so that only the tool-tips are displayed. Any Suggestions?ThanksDave

Link to post
Share on other sites

I believe JavaScript provides no access to the title attribute except the actual text. So I don't see a way here.Since alt text only appears if the image is broken, it might make sense to have no title attribute at all and put your text in the alt attribute, if that is possible.A slightly worse but doable way to stash data easily is to create an attribute and just write it into your image tag. Call it anything that is not a reserved word. JavaScript can find it using reference_to_element.getAttribute('name_of_attribute'). This works in Firefox and Safari. I don't remember if IE supports it.The downside is that the page won't validate. If you don't care about that, then it's not a real problem. You would just have to adjust your tooltip code to make this work.You can also attach properties to an element using JavaScript. That's a little more complicated than writing text into a tag, but it's legal and won't hurt validation.

Edited by Deirdre's Dad
Link to post
Share on other sites

Thanks for the replies Here is part of the code I am working with.<a href="upload.asp?id=<%= session("ID")%>" title="Upload Photos" alt="" rel="gb_page[500, 350]" onMouseover="ddrivetip('<center>Upload Photos</center>','#ddeeff', 50)"; onMouseout="hideddrivetip()"><img src="images/upload.gif" width="16" height="16" border="0" title="" alt=""></a>So actually, the Title is applied in the anchor rather than the image...Anyway, the title="Upload Photos" is used by the pop-up script as the caption in the header bar of the pop-up. I can set title="" and I do not get the default alt/title message, however, I also do not get the caption in the pop-up.The .js file for the pop-up is compiled, and I have no means of addressing this within the script, so I would like to find a way to simply prevent the browser from displaying it's own message.ThanksDave

Link to post
Share on other sites

I don't know of a way to do that, you would probably need to use an attribute other than title and modify the Javascript to handle that. Even if the source is minified you should be able to run it through something like jslint to reformat it (Javascript code is not compiled). Another way might be to set the title to blank on mouse over and reset it back to the original value on mouse out.

Link to post
Share on other sites

Strange. I Googled 'ddrivetip', which is the function called in your link, and found a very old-fashioned script (here)that does what you're talking about. From what I can tell, it's the original, and it has not been obfuscated or compressed.So it can be edited.Except that it doesn't really need to be to do what you want. It doesn't do ANYTHING with the alt or title text. So you could probably use it as a drop-in replacement for what you've got. (If you try that, work with a copy of your document so you don't permanently mess something up.) The thing that has been worrying me is that your call to ddrivetip() passes an argument it doesn't seem to be using, if in fact it grabs text from the title attribute. So I'm thinking what you're using is a kind of half-finished update of the original script. OTOH, as I said, the script I linked you to is old and does a lot of stuff it doesn't need to so that it is compatible with really old browsers (like IE 5.5). It seems to work fine as is, but if you wanted to, and you know how, you could cut a lot of the code, and have a tidier package.An idea.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...