Connecting Tech Pros Worldwide Forums | Help | Site Map

Add title inside link tag to make tooltip

Newbie
 
Join Date: Jul 2007
Posts: 3
#1: Jul 28 '07
Hi. I'm beginner to Javascript so my question maybe would sound dumb to you.

Anyway, I'm editing a script for my blog and a line goes like this:

document.write('<a href="' + alturl + '">' + entry.author[0].name.$t + '</a>' + ':' + ' ');

What I want is add the title="' + posttitle +'" inside the link tag to make the title of the post a tooltip. However, adding that one messes things up and the whole thing won't appear on the page anymore.

epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Posts: 1,313
#2: Jul 28 '07

re: Add title inside link tag to make tooltip


Quote:

Originally Posted by casperrr

Hi. I'm beginner to Javascript so my question maybe would sound dumb to you.

Anyway, I'm editing a script for my blog and a line goes like this:

document.write('<a href="' + alturl + '">' + entry.author[0].name.$t + '</a>' + ':' + ' ');

What I want is add the title="' + posttitle +'" inside the link tag to make the title of the post a tooltip. However, adding that one messes things up and the whole thing won't appear on the page anymore.

Hi casperrr welcome to TSDN,

try this:
Expand|Select|Wrap|Line Numbers
  1. document.write('<a href=\'' + alturl + '\' title=\''+ posttitle +'\'>' + entry.author[0].name.$t + '</a>' + ':' + ' ');
  2.  
Please next time use code tags....[ code=javascript][ /code] (without the spaces).

good luck
Newbie
 
Join Date: Jul 2007
Posts: 3
#3: Jul 30 '07

re: Add title inside link tag to make tooltip


Quote:

Originally Posted by epots9

Hi casperrr welcome to TSDN,

try this:

Expand|Select|Wrap|Line Numbers
  1. document.write('<a href=\'' + alturl + '\' title=\''+ posttitle +'\'>' + entry.author[0].name.$t + '</a>' + ':' + ' ');
  2.  
Please next time use code tags....[ code=javascript][ /code] (without the spaces).

good luck

Thanks. The code now works. However, the tooltip would show the link tag for the postitle. That is, for example,

[HTML]<a href="http://MYBLOG.blogspot.com/2007/07/post-title.html">post title</a>[/HTML]

Other instances of "posttitle" in the script would show the real title unlike this one. I'm using Blogger by the way if that helps.
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Posts: 1,313
#4: Jul 30 '07

re: Add title inside link tag to make tooltip


Quote:

Originally Posted by casperrr

Thanks. The code now works. However, the tooltip would show the link tag for the postitle. That is, for example,

[HTML]<a href="http://MYBLOG.blogspot.com/2007/07/post-title.html">post title</a>[/HTML]

Other instances of "posttitle" in the script would show the real title unlike this one. I'm using Blogger by the way if that helps.

i don't understand what u mean...do u have live code i can see?
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Jul 31 '07

re: Add title inside link tag to make tooltip


Changed the thread title.

Please read Use a Good THread Title.
Newbie
 
Join Date: Jul 2007
Posts: 3
#6: Jul 31 '07

re: Add title inside link tag to make tooltip


Quote:

Originally Posted by epots9

i don't understand what u mean...do u have live code i can see?

The script containing that is here.

The blog is here. The function is applied on the widget named "recent comments" below the page. If you can see, mouseover the links there and the tooltip will show the a tag for the title.

If you understand German, spare the posts. I just translated them from somewhere to act as trial posts. Hehe.

Really big thanks.
Reply