Extension:LinkTarget/ja

The LinkTarget extension allows admins to add a  attribute to internal and external links. That can be used to, for example, open internal and external links in new windows.

This extension was created for WikiWorks.

設定

 * $wgLinkTargetParentClasses
 * The descendants of elements of this class will have their target attribute set by the extension. Expects an array with the format:


 * If target is not specified or is invalid, the target will be set to . Note that it is also valid to specify one class as a string, instead of an array of classes.


 * $wgLinkTargetDefault: The default target for parent classes that do not have a valid target specified.
 * Can be set to:,  ,   or  . Defaults to.

Example 1: Open specific internal/external links in new windows
In LocalSettings.php: Adds  as an attribute to links that are children of an HTML element that belong to either class "foo" or "bar". To use in the wiki: This is some text with an Internal link and also an External link. In that example, both links will open in new windows or tabs.

Example 2: Open specific images in new windows
Using the same LocalSettings as in Example 1, in the wiki use:

Example 3: Open most links in a new window, but not these
In the wiki: This link will open in a new window, but not this one.

Example 4: Use with extensions
Surround extension parser functions or tags with some code and open any links generated by those extensions in a new window. As an example, we will use the Flickr API extension, with the LocalSettings code from Example 1:

Actually, that extension helpfully already surrounds any code that it generates with a class so really it is sufficient to set LocalSettings as follows: This will apply to all Flickr images generated by the extension. When users click on any image, the link will open in a new window or tab.

Advanced
Descendants of 'foo' will have target '_top', descendants of 'bar' will have target '_blank' and descendants of 'baz' will have target '_parent'.



既知の制限

 * The links will not have any special target while viewing the page in "preview" mode.

