View Full Version : changing title spec in anchor tag?

04-23-2004, 08:22 AM
I have some links that open in popup windows. I'd like to have a message when the cursor goes over the link to indicate that it is a "popup". I know I can do this with the title spec. But I only want it to show up only if javascript is enabled. I'd like a different title spec for viewers who have javascript disabled.

I have come up with the first version but it is a little unwieldy.

<a href="blahblah.html"
onclick="window.open('blahblah.html', 'popup', 'scrollbars=1,resizable=1,width=590,height=400,left=20,top=20'); return false;" title="blah blah">
blah blah link <script>
document.write("(opens in a popup window)");

This second version is my attempt at putting a "noscript" inside the anchor tag. But, of course, this doesn't work.

<a href="blahblah.html"
onclick="window.open('blahblah.html', 'popup', 'scrollbars=1,resizable=1,width=590,height=400,left=20,top=20'); return false; document.write(title='blah blah opens in a popup window ');"
title="blah blah">blah blah link</a>

Is there some way of doing this so that the title spec in javascript-enabled browsers will be "blah blah opens in a popup window" and in javascript-disabled browsers will be "blah blah"? (I hope my question made some sort of sense.)

Willy Duitt
04-23-2004, 08:42 AM
Use an onmouseover event handler and setAttribute ;)


<a href="blahblah.html" title="blah blah"
onmouseover="this.setAttribute('title','this is a javascript popup link')"
onclick="window.open(this.href, 'popup', 'scrollbars=1,resizable=1,width=590,height=400,left=20,top=20'); return false">blah.html</a>


04-23-2004, 04:11 PM
Aha! Thank you, Willy! That works perfectly.