Jump to content

Is their a way to use target="_blank" with CSS


airesofwar

Recommended Posts

So basically I am getting really sick of typing in target="_blank" through every link list. And I cant seem to find anything about using it as CSS. But their has to be some way to get this to work! Maybe even some type of script to add in to allow this.

Link to comment
Share on other sites

Well, technically you shouldn't be forcing links to open in new windows anyway - the attribute was deprecated for a reason. Nevertheless, it is not possible in CSS, as CSS defines presentational behaviour and the nature of hyperlinks is functional. It is possible to use JavaScript to insert the attribute, though, e.g.:

anchors = document.getElementById("linklist").getElementsByTagName("a");for (a in anchors) {	a.setAttribute("target", "_blank");}

Link to comment
Share on other sites

Dilated, If I am not mistaken that is CSS with regex which IE does not support.Synook, Yeah I figure it would end up coming down to javascript.Thanks for both your answer, but I think I will go with the javascript. As long as people are not blocking the scripts it should work.

Link to comment
Share on other sites

What? regex? Where? Nothing supports the hyperlink presentation spec yet. I was just pointing it out, but what made you think "regex" when you read my post?
The square brackets in the code made me think of "regex". Good chance 'm wrong tho lol!
Link to comment
Share on other sites

Yeah. No regex. Somehow I think that document will never fly. The argument that opening windows is presentation and not behavior is pretty cheesy. Might as well go back to target attributes in the <a> tag itself.

Link to comment
Share on other sites

The square brackets in the code made me think of "regex". Good chance 'm wrong tho lol!
That is an attribute selector. As far as I know, attribute selectors work with IE7+.I suppose technically they are sort of regexes, e.g. the [attr^=string] selector matches the beginning of the string using a caret, just like a regex would. But they are not really regexes, i.e. there's no pattern involved. I know regex selectors have been proposed for CSS, but nothing has been included in a spec yet.
Link to comment
Share on other sites

Yeah. No regex. Somehow I think that document will never fly. The argument that opening windows is presentation and not behavior is pretty cheesy. Might as well go back to target attributes in the <a> tag itself.
Yeah, I've always kind of thought this myself. Personally I don't think an author of a page should be able to decide how a user's browser will behave in regards to following links at all. I just thought it was one of the more interesting lesser-known drafts. I thought I'd point it out.
Link to comment
Share on other sites

I am not very familiar with regex myself. I only know I tired it once with trying to override some previous styles and I found it did not work in IE. I don't remember much about it only that it was contained in the square brackets. personally to me I do not even know why they bother to make some of this stuff. If its not going to be supported in the top 4 browsers, then its about pointless to use. Good example is radius borders and shadow text.

Link to comment
Share on other sites

I am not very familiar with regex myself. I only know I tired it once with trying to override some previous styles and I found it did not work in IE. I don't remember much about it only that it was contained in the square brackets. personally to me I do not even know why they bother to make some of this stuff. If its not going to be supported in the top 4 browsers, then its about pointless to use. Good example is radius borders and shadow text.
What are you talking about? regex selectors don't exist (yet). You're talking about attribute selectors which are supported in every major browser (including IE7+): http://en.wikipedia.org/wiki/Comparison_of...ts%29#SelectorsAside from that, never judge the quality of a feature based on whether it is supported in IE. IE is notorious for its stubbornness and refusal to support anything (it seems like every day I'll find something new wrong with IE). IE has been the single biggest hindrance on web development for the past decade.
Link to comment
Share on other sites

I am not very familiar with regex myself. I only know I tired it once with trying to override some previous styles and I found it did not work in IE. I don't remember much about it only that it was contained in the square brackets. personally to me I do not even know why they bother to make some of this stuff. If its not going to be supported in the top 4 browsers, then its about pointless to use. Good example is radius borders and shadow text.
I'm not familiar with regex's in CSS... :)border-radius and drop shadows are CSS3 properties. CSS3 is still in draft. So it should be no surprise that they aren't fully supported. There are a lot of features that are not implemented at all, but when CSS3 becomes a standard most of them (but not all, since some will be dropped by that time) will be fully implemented, or at least they should be.
Link to comment
Share on other sites

I'm not familiar with regex's in CSS... :)border-radius and drop shadows are CSS3 properties. CSS3 is still in draft. So it should be no surprise that they aren't fully supported. There are a lot of features that are not implemented at all, but when CSS3 becomes a standard most of them (but not all, since some will be dropped by that time) will be fully implemented, or at least they should be.
Anything in CSS3 that is at least at Candidate Recommendation status is essentially a standard and is ready to be implemented by user agents. (Arguably, even last call working drafts are standards and should be implemented, and they are, as you can see in Firefox, Chrome/Safari, Opera - As far as I know (haven't checked yet), Firefox 4 is removing vendor prefixes from border-radius and box-shadow and Opera never had them to begin with).http://www.w3.org/Style/CSS/current-workMost people seem to think something only becomes a standard once it reaches Recommendation. Recommendation status is only achieved after the fact; after the spec has had several major implementations and is considered a success. For example, the CSS 2.1 draft was written up more than 8 years ago and it is still only at candidate recommendation: http://www.w3.org/TR/CSS2/
Link to comment
Share on other sites

I know those are not regex property's, I was referring to the code Dilated provided above.Yeah IE is a pain to say the least, but still most people refuse to use FF. So we are forced to design based on what IE supports right now. I was not aware that IE was not supporting it due to it still being in still being in draft. So that is good news to hear IE9 might support shadow-text and radius borders. Because I would like my sidebar h2 to to have round corners with shadow text in them. Right now we are forced to use images in place of that. But it would be a lot more user friendly to just style it with CSS property's.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...