John Assymptoth
John Assymptoth

Reputation: 8507

Using CSS to emulate <a target="_top">

Is it possible to alter a link behavior to target="_top" via CSS?

Edit: Soon, my friends, soon. :)

a[target="_top"],
area[target="_top"],
form[target="_top"]
  { target: root }

http://www.w3.org/TR/css3-hyperlinks/

Upvotes: 0

Views: 2051

Answers (3)

Jonathan
Jonathan

Reputation: 5028

No, but you could set a class="top" in your a tag, and then use javascript (via jQuery) to alter its behaviour:

$(function() {
  $('.top').attr('target','_top');
});​

jsfiddle: http://jsfiddle.net/brRHP/3/

Upvotes: 1

kapa
kapa

Reputation: 78741

No, it is not possible. CSS is for presentation.

EDIT: The CSS3 Hyperlink Presentation Module talks about making this possible, but it is only a Working Draft and is not supported by any browsers.

Upvotes: 5

Sablefoste
Sablefoste

Reputation: 4192

No, but add a <div id="top"></div> to the top of your body text. Then have your anchor refer to index.php#top (if your page name is index.php)

Upvotes: 0

Related Questions