Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-23-2004, 07:22 AM   PM User | #1
llizard
Regular Coder

 
Join Date: Apr 2004
Location: Canada
Posts: 302
Thanks: 2
Thanked 0 Times in 0 Posts
llizard is an unknown quantity at this point
Question changing title spec in anchor tag?

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.

Code:
<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)");
</script></a>
This second version is my attempt at putting a "noscript" inside the anchor tag. But, of course, this doesn't work.

Code:
<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.)
llizard is offline   Reply With Quote
Old 04-23-2004, 07:42 AM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Use an onmouseover event handler and setAttribute

eg:
Code:
<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>
.....Willy

Last edited by Willy Duitt; 04-23-2004 at 08:07 AM..
Willy Duitt is offline   Reply With Quote
Old 04-23-2004, 03:11 PM   PM User | #3
llizard
Regular Coder

 
Join Date: Apr 2004
Location: Canada
Posts: 302
Thanks: 2
Thanked 0 Times in 0 Posts
llizard is an unknown quantity at this point
Thumbs up

Aha! Thank you, Willy! That works perfectly.
llizard is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:31 PM.


Advertisement
Log in to turn off these ads.