/    Sign up×
Community /Pin to ProfileBookmark

Making the "title" of a link the same as the text of the link?

Hi Everyone:

I am trying to get the title attribute of a link to be the same as the visible text of the link. That is, I want the little pop up that occurs when you hover your mouse over the link to read the same as what users would see in the menu.
The menu is written by Javascript, so there is no way to just put a title attribute on each link. Here is the code:

[CODE]// “For” loop which creates all of the inline JavaScript anchor tags
for (var i = 1; i <= iNumMarkers; i++) {
sTempString = sTempString + ” <li><A HREF=”javascript:parent.seekToMarker(“;
sTempString = sTempString + i + “)”title=”Click the Link You Would like to Listen To.”>&nbsp;”;
sTempString = sTempString + document.MediaPlayer1.GetMarkerName(i);
sTempString = sTempString + “&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</A></li><BR>”
}
[/CODE]

The code reads the Marker name from a separate file and places it into an I-Frame. I got the I-frame working ok, as well as the links. The links in the Iframe though need to have a title that is the same as the link. I hope that makes sense. If not ask and I’ll try to clarify. I have attached the actual page if you need to see more code.
Bill

[upl-file uuid=94ffb3af-a3b6-425f-b0b0-12aea2757d51 size=7kB]wmplayer.txt[/upl-file]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@blis102Aug 01.2007 — Hey Mechman2,

Fist off, could you include all the files that are relevant (the CSS, iframe page, etc..) into a zip file or upload your code to the net and post the link so that I can check out the whole setup you have? That will help in finding the problem.



On another note, there are a few things about your code that I could offer suggestions on, here goes:

First, all your html tags should be lowercase (<a href=""> not <A HREF="">) especially if you site has a doctype of XHTML transitional or strict (which it does). It is invalid (and pointless) to capitalize html tags, and is just generally a good practice to not use capitals in your code.

Second, inserting 20 &nbsp; tags is really the wrong way to go about building a web page. Instead use the power of CSS to add padding to whatever element needs that many spaces. Apply a class to the link and then give that class a padding in CSS.

Third, why would you want the title of the link to be the same as the link? A title tag is meant to give MORE information to the user, not the same information. Your title tags should be explanatory, they should give the user a better idea of what the link will do or where it will take them.

Fourth, you should get into a habit of separating your CSS, Javascript and HTML from each other (in seperate files ideally) so that editing of the page is much easier, and future changes are sped up. Google "unobtrusive javascript" and "external css" to get some idea of what im talking about. Heres a good link about external css http://www.tizag.com/cssT/external.php to get you on your way

Fifth, It appears to me that you are using Dreamweaver (or something similar) to write your code for you? If thats the case, you should really get into the habit of writing as much code as you can by hand so that you have an intimate knowledge of the underlying structure of your page. If you come across an error, you will have a much better chance and finding and fixing it.

Sorry for such a long winded reply (and if I sounded preachy at all), but I wanted to make you aware of a few of the things I saw that could be improved within your code.

Post that zip soon so I can help you more.

Thanks
Copy linkTweet thisAlerts:
@mechman2authorAug 02.2007 — Hi Blis102:

Thanks for the offer of help. I already got help from someone. Here is the code he gave that works incase anyone is interested:
[CODE]// "For" loop which creates all of the inline JavaScript anchor tags
for (var i = 1; i <= iNumMarkers; i++) {
sTempString = sTempString + " <li><A HREF="javascript:parent.seekToMarker(";
sTempString = sTempString + i + ")"title="" + document.MediaPlayer1.GetMarkerName(i) + "">&nbsp;";
sTempString = sTempString + document.MediaPlayer1.GetMarkerName(i);
sTempString = sTempString + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</A></li><BR>"
}[/CODE]


The Javascript and html code on this page was written by someone else. I was just trying to modify it enough to do what my boss wanted. He is the one that wanted the popup the occurs when you hover over a link to be the same as the link. (Its all written in a Javascript loop...).

I'm going to try to "clean up" the page today by fixing some of the issues you said. Thanks again for the offer of help.

Bill
×

Success!

Help @mechman2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...