Edgewall Software
Modify

Opened 10 years ago

Last modified 5 years ago

#10376 new enhancement

Opening a link in a new window?

Reported by: jennifer.johns@… 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)

comment:1 by Remy Blank, 10 years ago

Component: generalwiki system
Keywords: bitesized added
Milestone: next-major-0.1X
Type: defectenhancement

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 the target 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.

in reply to:  1 ; comment:2 by rpg2424@…, 10 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 the target attribute doesn't exist in that DTD.

Change it and make it work please, hiding behind DTD is crippling the software.

in reply to:  2 comment:3 by Remy Blank, 10 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 gavenkoa <gavenkoa@…>, 9 years ago

New HTML 5 standard allow use of target for a tag:

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 gavenkoa <gavenkoa@…>, 9 years ago

Cc: gavenkoa@… added

comment:6 by Carsten Klein <trancesilken@…>, 6 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 Ryan J Ollos, 6 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!
Visit Genshi for a great Python templating engine!
Last edited 6 years ago by Ryan J Ollos (previous) (diff)

comment:8 by tim@…, 5 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).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.