Opened 13 years ago
Last modified 8 years ago
#10376 new enhancement
Opening a link in a new window?
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | normal | Milestone: | next-major-releases |
Component: | wiki system | Version: | |
Severity: | normal | Keywords: | bitesized |
Cc: | gavenkoa@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
What code is necessary for me to create a link that will open in a new window, as opposed to opening within the existing window? I am including a link on a new webpage on gsa.gov that will take the customer away from the GSA site and onto a non-government site.
Attachments (0)
Change History (8)
follow-up: 2 comment:1 by , 13 years ago
Component: | general → wiki system |
---|---|
Keywords: | bitesized added |
Milestone: | → next-major-0.1X |
Type: | defect → enhancement |
follow-up: 3 comment:2 by , 13 years ago
Replying to rblank:
That's not really possible with a stock Trac. The usual way to do this is to add a
target="_blank"
attribute to the<a>
tag of the link. But Trac is generating XHTML 1.0 Strict, and thetarget
attribute doesn't exist in that DTD.
Change it and make it work please, hiding behind DTD is crippling the software.
comment:3 by , 13 years ago
Replying to rpg2424@…:
Change it and make it work please, hiding behind DTD is crippling the software.
Thanks for the patch. Oh, wait, no patch to be found. Never mind…
comment:4 by , 12 years ago
New HTML 5 standard allow use of target
for a
tag:
- http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#browsing-context
- http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#attr-hyperlink-target
- http://stackoverflow.com/questions/4198788/is-it-alright-use-to-target-blank-in-html5
Quotation from http://www.w3.org/TR/html5-diff/ :
The target attribute of the a and area elements is no longer deprecated, as it is useful in Web applications, e.g. in conjunction with iframe.
comment:5 by , 12 years ago
Cc: | added |
---|
comment:6 by , 10 years ago
AFAIK I have some code flying around here somewhere that would add links to the wiki that will open in a new window/tab. I have to dig out my old repositories but I am sure that I can find it.
comment:7 by , 10 years ago
Since milestone:1.0.2 (#11127) we have the trac-target-new
class. It sounds like the only thing needed for this ticket is a way to decorate TracLinks with the class.
Visit <a class="trac-target-new" href="http://genshi.edgewall.org">Genshi</a> for a great Python templating engine!
comment:8 by , 8 years ago
Being able to specify arbitrary links to open in a new tab improve my ability to write good documentation (also see #9134).
Until this is resolved within Trac, ExtLinkRewriterPlugin – Trac Hacks can be used to achieve the same results (albeit for all links of the specified protocols).
That's not really possible with a stock Trac. The usual way to do this is to add a
target="_blank"
attribute to the<a>
tag of the link. But Trac is generating XHTML 1.0 Strict, and thetarget
attribute doesn't exist in that DTD.You could write a small plugin with a macro that expands to a
<a href="javascript:window.open(...)">
tag, or adds a new form of TracLinks for this purpose. Maybe there's even already one on trac-hacks.Actually, this could even be a good addition to Trac core. For example, we could extend the
[realm:resource]
syntax, where a ^ prefix to the realm would mean "open in a new window" (e.g.[^wiki:WikiStart]
). Or something more intuitive.