[Jump to navigation]

Post #58

Nice Titles revised

Screen shot of the modified Nice Titles in action

You may have noticed I’m using Stuart Langridge’s Nice Title script on this site. With the help of Ethan I’ve made a couple of modifications to the original version, so I thought I’d highlight them here and let you grab a copy if you wanted.

The pause

A common complaint when Stuart’s script was originally launched was the lack of delay present between mousing over a link and having the pop-up appear. (Browsers tend to have a pause before showing their pop-ups, letting you waft your mouse over groups of links without multiple boxes flickering madly on screen.)

Ethan put his Magic BrainTM to work and solved this problem with a neat little timer function. So now we have a customisable delay between mousing over a link (or tabbing focus to it), and having the pop-up appear. It’s currently set to 0.6 seconds on this site, which seems to be the same as the browser’s own delay. Please Let me know if that’s too much, or not enough.

Access keys

Access keys are a handy way to access web site links via the keyboard. Some of the links on this site have access keys associated with them (specifically the main navigation links) and I wanted to be able to show this information in the pop-ups. In the image that accompanies this post you should be able to see that the access key (the letter ’c’ in this case) is displayed in the pop-up. (It’s also shown beside the menu item itself, but that’s down to some CSS in my main style sheet.)

img, ins and del

This version of the code also works for images that are linked, sections that have been inserted and marked with the ins tag, and sections that have been deleted and marked with the del tag. I must admit to simply bringing a couple of different versions of the code together for that, mainly from the work of Peter Janes.

Anyway, that’s the lot. Thanks again to Stuart (for starting it), and to Peter and Ethan (for doing the bits I couldn’t). Feel free to grab the code here and improve on anything we’ve done.

Update: After comments from Jeremy I discovered that something about my CSS (the weather header) causes IE to offset the pop-up display by 175px. Rather than spend forever messing about, I’ve just blocked IE from running this script. It will run happily on other sites, just not on mine.

Jump up to the start of the post


Comments (16)

Jump down to the comment form

Note: For those visitors with Javascript enabled, clicking on a comment will highlight it and all those comments that relate to it. A red border shows the comment in focus, green borders signify parent comments, blue borders signify child comments. Read more…

  1. Dunstan:

    If anyone's wondering, I removed the transparent PNG from the CSS and replaced it with a solid background colour. I then applied Moz-only opacity to it.

    Why? Well, the image was taking too long to load for my liking, leaving users with an un-usable popup for a few seconds.

    I prefer that everyone gets usable, and a few get fancy.

    21st Nov 2003 at 18:09 GMT
  2. Jeremy C. Wright:

    Hey,

    I'm not sure if I'll use this on my site or not, however there are some bugs to this it seems.

    I'm on XP Pro (patched) running IE6 (patched) and get some buggy behaviour for links in the body of comments: the popup appears at or near the bottom of the screen...

    Actually, trying it out it seems like a pixel-offset, though I'm too lazy to open PhotoShop and see how many pixels it is.

    Good luck fixing the bug.

    J

    21st Nov 2003 at 18:09 GMT
    Commentors inspired by this post: ↓ Dunstan, ↓ Dunstan
  3. Dunstan:

    Hey, that's odd - you're right J, it does it to me as well on IE6 - but it works fine on my off-line test pages :o/

    There must be something odd in my site making it freak out. (It's fine in Moz.)

    21st Nov 2003 at 18:14 GMT
    Commentors that inspired this post: ↑ Jeremy C. Wright
    Commentors inspired by this post: ↓ Dunstan
  4. Dunstan:

    Yes, it turns out IE is offsetting the popups by the height of my weather header. It only happens in the main body of the page, not on the navigation menu.

    It only seems to do this on my site, which is helpful :o)

    I think I'll block IE from running the script here, but leave the downloadable version unchanged.

    Why don't I ever spot these things during testing?...

    21st Nov 2003 at 18:45 GMT
    Commentors that inspired this post: ↑ Jeremy C. Wright, ↑ Dunstan
    Commentors inspired by this post: ↓ Dunstan
  5. Dunstan:

    IE6 duly blocked... shame, but there we are.

    21st Nov 2003 at 19:21 GMT
    Commentors that inspired this post: ↑ Dunstan
    Commentors inspired by this post: ↓ Matt
  6. Matt:

    I love the new "screw IE" mentality amoung web developers on independent sites. It's a natural backlash to the way we must bow down to it in professional work.

    21st Nov 2003 at 19:55 GMT
    Commentors that inspired this post: ↑ Dunstan
  7. Matt:

    Oh, another reason why this is useful is Moz seems to trunucate long titles and end them with a "..." where IE will just display everything in the title. This is espescially annoying on link blogs (such as Anil Dash's) where the commentary in the link titles is some of the best stuff but to see it all I have to view source, at which point nothing is clickable anymore so I have to bounce between windows if I feel the link is worth following.

    21st Nov 2003 at 19:59 GMT
  8. Stefan:

    This is a very nice approach to style the normal pop-up (although pop-up isn't the right word for it, I like hove-over more) of links.

    But there is one problem: the pop-up is positioned relatively to the link itself, as opposed to the mouse position what would seem more logical.

    But there is a real problem too: when the same link resides on two lines (like the 'let me know' link in your post) the pop-up is located at the right side of the link. Thus giving some strange results when hovering over the word 'know'.

    21st Nov 2003 at 21:35 GMT
  9. Stuart:

    I have been entirely lax in not thanking you chaps for hacking on nicetitles to make it better, I must admit. Sorry; tied up frantically at the moment, if you'll excuse the phrasing. Excellent work, I say. I vacillate myself between a PNG background and an opacity setting; the opacity method allows rounded corners on the titles, but you can't (easily) set the opacity of the background but not the text thereupon. These things are sent to try us, I suppose. :-)

    22nd Nov 2003 at 00:33 GMT
    Commentors inspired by this post: ↓ Dunstan
  10. Dunstan:

    Hey Stuart - not a problem, it's great to have the script to start with, I'd never be able to write it from scratch :o)

    The opacity thing isn't hard though - just set one opacity for the div, and then another for the text - that's all, only two lines of css. E.g.:

    div.nicetitle {-moz-opacity: .87;}
    div.nicetitle p {-moz-opacity: 1;}

    22nd Nov 2003 at 00:42 GMT
    Commentors that inspired this post: ↑ Stuart
    Commentors inspired by this post: ↓ Stuart
  11. Stuart:

    Do you know, if I had half a brain, I'd be dangerous. Naturally I was just about to think of styling the paragraphs *inside* the div, but, er, er, I was getting a cup of tea, yeah, that sounds plausible... :-)

    22nd Nov 2003 at 00:48 GMT
    Commentors that inspired this post: ↑ Dunstan
  12. Michael Heilemann:

    I am having problems with nicetitles and image links (you can try out the images on the sidebar of my blog [1]). I don't know if this is a general problem or something I'm missing, but if anyone has a suggestion or two I'd be more than willing to try it out :)

    [1] http://binarybonsai.com

    22nd Nov 2003 at 11:28 GMT
    Commentors inspired by this post: ↓ Dunstan
  13. Robert Castelo:

    Good work!

    You also seem to have fixed the problem with Mac OS X Safary - befor it poped up a JavaScript Alert each time I went over a link - which somewhat degraded usability ;-)

    23rd Nov 2003 at 01:37 GMT
  14. Marten:

    Great script. I was wondering, wouldn't it be handy to do this on the acronym tag as well?

    2nd Dec 2003 at 18:27 GMT
    Commentors inspired by this post: ↓ Marten
  15. Dunstan:

    Michael, (I think you're moving house or something right now) I too had image-link problems with the old version, but I think I fixed it in my version - did you try that yet?

    I think I had to add in some extra code - anyway, it works on this site, lemmie know it my version falls over at your place.

    4th Dec 2003 at 23:51 GMT
    Commentors that inspired this post: ↑ Michael Heilemann
  16. Marten:

    Just send dunstan the update I did myself. It now supports all tags (still user-selected, but extendible by editing an array). Hope he posts it, I don't have a blog to host it.

    6th Dec 2003 at 20:17 GMT
    Commentors that inspired this post: ↑ Marten

Add your comment

Note: If your comment directly relates to any previous comments, try checking their ‘Link to this entry’ boxes and help maintain inter-comment relationships. Read more…




Hug the Cookie Monster?

Spammers take note: any comments deemed to be spam will be removed. Any linked domains will be added to a publicly available blacklist file. You will then be unable to post to this site in future.
Any other content deemed inappropriate or offensive may be edited and/or deleted.