How can I add a "open-in-new-window"-icon to my hyperlinks
So, i don't like links that automatically open in a new window, but i want to give my user the ability to, without using shift+leftclick. I want to add an miniicon for doing so right to my links. Do you know how I am able to do this by use off CSS?
Chronistin
I think this is the most-used script for toggling the target-window.
nex
this works fine, but only with JavaScript. client side. to automatically include the icon Zytostat actually wanted, we would have to add a new feature to antville; you can't do this within a blog alone, because there is no skin for links. maybe you should issue a feature request (this sounds like a very nice, desirable feature!) or implement it yourself.
AFAIK, there is no proper way of doing this with CSS. i'm sure you can't do it with CSS 1.x or CSS 2.0.
if i'm bored later today, i'll try to draw a tiny icon that conveys the meaning "link will open in new window if you click me, but not if you click the text next to me". however, i'm afraid today i will be very occupied with sleeping, because i worked throughout the night.
tinto
but you could add a piece of code like this into the "create a story" skin below the text area. Everytime you want to add a Link, just copy&paste it
<a target="_blank" href="http://www.xyz.com/;><img src="your_icon.gif" alt="open Link in new window"></a> <a href="http://www.xyz.com/">Text</a>
It's much less typing work. Even better: a programm like Gosttyper, that could add your code including the "http://www.xyz.com/" from the clipboard.
nex
that's certainly a working method, but you have to be aware of its limitations. if you just do all the work on the client side, you could come up with something even less clumsy than the ghosttyper approach, e.g. a little script in the story creation skin that adds the code mentioned above. but if the code is saved along with the story, you get into trouble if you want to change anything about the icon because you'd have to change it in each and every story.
tinto
I don't understand the goal anyway, people (readers!) who want links to open in a new browser window should be able to open it themselves.
(maximum dummy service I would provide is a hint how to do that, for example "Use your shift key in order to ...")
nex
you have to press the shift key to open a link in a new window? you have to use a second hand? this is so 20th century! i just drag the mouse down a few pixels while clicking the link.
but of course you are right, links opening in new windows by default are annoying most of the time. there are just some exceptions, when you cann assume that a reader will open several links in new windows, e.g. in an article that references the sources the author used. most readers will want to open those links that look interesting to them, but in another window, because they also want to read on in the article. consequently, it would be more convenient for them if the links were that way by default. but because links that open in new windows without a warning are annoying, it is good practise to add little icons to them. telepolis, for example, do this very nicely (with intuitively understandable icons).
so, yes, an icon that opens the link in a new window, whereas the link itself does not, is totally useless.
tinto
> you have to use a second hand?
No, I don't. Just used this as an example, because I guess it's working in almost every browser.
(BTW: Sites that open new windows by default are punished with my ignorance. And: if I open anything it's a tab not a window ;-)
nex
You're lucky that I don't ask in which way a tab wouldn't be a window now, because you couldn't explain – it's the same thing. The real, actual difference between 'tabbed' and 'non-tabbed' browsing is that the further provides an MDI (multiple document interface, i.e. multiple documents in one application window) and the latter provides an SDI (single document interface, i.e. one application window per document). In the MDI you have one window, yes, window, per document inside the big window, and the tab bar as a means to switch between them. If those windows are maximised, this isn't obvious and it's in fact unnecessary to make the distinction. However, as 19" and bigger screens are becoming common (for desktops on which you run browser in which you open links in new windows; you don't do that on your handheld), having browser windows maximised is really crazy. Some layouts are pulled apart so that 200 or 300 letters fit in one column of text, which consequently suffers a lot in readability, and others leave more than half of the window blank. For some sites (e.g. newspaper-ish ones with sidebars and stuff), it would be really nice to have a layout that sensibly utilises big windows while still looking okay in small ones, but that isn't really possible in HTML.
And yes, the shift key method is working in almost every browser, but only if you just look at the browsers that are designed to activate links by clicking on them with a pointing device and to be used with a keyboard. There are lots of browser that are different. Anyway, an example that involves a second hand isn't very good, because that case would really justify a convenient icon that allows you to quickly open a link in a new window while still holding on to your book, cup of coffee or genitalia or whatever.