SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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>"
    	}
    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
    Attached Files Attached Files

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    going from your code, you should only need to use

    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>"
        }


  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Virginia
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    	for (var i = 1; i <= iNumMarkers; i++) {
    		var link_text = document.MediaPlayer1.GetMarkerName(i);
    		sTempString = sTempString + "  <li><A HREF=\"javascript:parent.seekToMarker(";
    		sTempString = sTempString + i + ")\"title=\"" + link_text + "\">&nbsp;";
    		sTempString = sTempString + link_text;
    		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>"
    	}
    That wouldn't put the visible text in the title tag of the link your outputting? Or did I completely misunderstand...
    Mark A. Drake
    - Mark A. Drake
    - OnSlaught

  4. #4
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    qRoberts:
    Thank you! I spent an hour and a half trying every combination I could think of. I greatly appreciate it! The pop up Title tags look great!! Thanks again, and again, and again!
    Bill

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,799
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The title is supposed to provide a more detailed description. Having it the same as the text is pointless.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Felgall:

    My boss wanted it like that...
    Bill


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •