On 30/03/07, Donna Jones <[EMAIL PROTECTED]> wrote:

> Have the href attribute point at something sensible (not #). Have the
> JavaScript do what you want, and return false from it to prevent the
> link being followed.

i suppose i understand what you're saying but i don't know javascript, i
don't know the syntax, so pretty impossible for me to implement.


I think he's suggesting something along these lines:

<a href="mypage.html" onclick="window.open(this.href);return false;">Click
me</a>

To break it down:

* By putting the page you're linking to in the href, it means that folks
without JS can still get to your content - it simply won't open in a new
page for them.
* The onclick attribute says that when the link is activated, do the things
in the quotes.
* window.open(this.href); tells it to open the page in this tag's href in a
new window. You can look up the syntax for this via Google if you want to
learn about all the other parameters you can set for the new window (just
throw "window.open" at Google and you'll get a bunch of useful pages).
* return false; tells it that after it's opened that new window, don't do
anything else. Without this, your page will open in a new window and also in
the original window. And because it's JS, it makes absolutely no difference
to the people with JS off or unavailable. The link will fire as normal and
they'll get the page in the current window.

Of course, if you wanted to be really clever about it (and more conscious of
keeping the presentation and behaviour layers separate) you'd write a
function that would attach this to the link without the need to have it
hard-coded in like this. All you'd do is create an href link as normal and
give it a class or id. That you'll need someone else to explain to you,
since I know how to borrow code to make this happen but don't fully
understand how it works. ;)

Cheers,

Seona.


*******************************************************************
List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: [EMAIL PROTECTED]
*******************************************************************

Reply via email to