Fandom Developers Wiki
Advertisement

ExternalLinkWarning shows a warning dialog when an external link is clicked allowing the user to back out of following the link.

Installation

Configuration

Dialog text

For site-wide use the text used in the dialog can be overridden by creating MediaWiki:Custom-ExternalLinkWarning which should contain a single line with the following format.

title|message|continue|cancel
  • title is the title of the dialog. Default is External Link.
  • message is the message given in the body of the dialog. You can use $1 in the message, this will be replaced by the links URL. Default is You are following a link to $1, a site that is not part of Fandom. Are you sure you wish to do this?.
  • continue is the text shown in the continue button. Default is Continue.
  • cancel is the text shown in the cancel button. Default is Cancel.

All of the above are optional. For instance to just change the continue button to say OK use.

||OK

The text does not have to be in English.

Pages

You can control what pages ExternalLinkWarning will affect by defining one or both of following variables:

Variable Type Purpose
ExternalLinkWarningNamespaces Array of strings If this variable is defined the script with only be active on pages in the supplied canonical namespaces.
ExternalLinkWarningPageRegex Regular expression If this variable is defined the script will only be active on pages whose path matches the supplied regular expression.

Examples

To limit the script to forums, and message walls:

window.ExternalLinkWarningNamespaces = ['Forum', 'Thread', 'Message_Wall'];

To limit the script to articles that start with the prefix "Decks/":

window.ExternalLinkWarningPageRegex = /^\/wiki\/Decks\//;

If using the script personally these should be added before the importArticles. If using the script globally then these definitions should be placed in the site global JS file.

If both variables are defined the script will only be active on pages that meet both criteria.

Demo

Click here to view the warning.

Dependencies

See also

Text above can be found here (edit)
Advertisement