跳转到内容

Help:外部链接图标

维基百科,自由的百科全书

外部链接通常会在链接末尾显示一个图标。系统使用CSS检测特定的文件扩展名URI方案,并根据所选皮肤显示对应文件类型的图标。

本页面包含用于演示链接图标的示例URL。显示的图标仅取决于URL本身,系统不会检查该链接是否实际存在对应类型的文件。此处示例均不指向真实文件。

说明

[编辑]

MediaWiki软件通过检测URI方案和/或文件扩展名来创建链接;因此不带URI的链接不会应用外部链接样式。MediaWiki不会尝试通过检测URL中的任何部分(如www)来创建链接,因为许多网站的URL并不包含这些内容。

皮肤Vector和Cologne Blue仅显示PDF图标。Modern、MonoBook和Timeless显示完整的文件扩展名图标集和部分URI方案图标;移动版Minerva则不显示任何图标。除PDF图标外(只要文件名扩展名中包含“pdf”就会显示),所有图标均由各皮肤的CSS定义。[1]

仅当扩展名完全匹配时才会显示对应的文件扩展名图标。文件扩展名图标的优先级高于URI方案图标。如果页面渲染时链接文本中存在换行,浏览器可能会显示空白或错位的图标。由于无法添加替代文本,这些链接图标不符合无障碍访问标准

示例

[编辑]
使用这些链接查看本页面在不同皮肤下的显示效果:
类型 文件扩展名 示例链接
PDF .pdf .PDF, .pdf# .PDF# .pdf? .PDF? http://example.org/test.pdf
AVI .avi .AVI http://example.org/test.avi
MPEG-1 .mpg .MPG .mpeg .MPEG http://example.org/test.mpg
Ogg .ogm .OGM http://example.org/test.ogm
MIDI .MID .midi .MID http://example.org/test.mid
MP3 .MP3 http://example.org/test.mp3
Vorbis .OGG http://example.org/test.ogg
WAV .WAV* http://example.org/test.wav
Windows Media Audio .wma .WMA http://example.org/test.wma
类型 URI方案 示例链接
IRC irc:// ircs:// irc://example.org
FTP ftp:// ftp://example.org
NNTP news: news:example.org
mailto英语mailto mailto: mailto:example@example.org
HTTPS https:// https://example.org/test.html
Subversion svn:// svn://example.org/
比特币 bitcoin: bitcoin:1BitQEtcoxAnViwUYX9k6KupmmsEfWrGnr
FTPS ftps:// ftps://example.org/
Geo URI英语Geo URI geo: geo:37.786971,-122.399677
Git git:// git://example.org/
Gopher gopher:// gopher://example.org
HTTP http:// http://example.org
磁力链接 magnet:// (stub)
多媒體短訊 mms:// mms://example.org/
NASA World Wind worldwind:// worldwind://example.org/
網路新聞傳輸協定 nntp:// nntp://example.org/
Secure Shell ssh:// ssh://example.org/
安全對話啟動協定 sips:// sips://example.org/
對話啟動協定 sip:// sip://example.org/
SMS sms: sms:1
SSH文件传输协议 sftp:// sftp://example.org/
电话 tel: tel:1
Telnet telnet:// telnet://example.org/
统一资源名称 urn: urn:isbn:0451450523
XMPP xmpp:// xmpp://example.org/

隐藏链接图标

[编辑]

可以使用plainlinks类或{{Plain link}}模板隐藏链接图标,但不建议这样做。

<span class="plainlinks">http://example.org/test.pdf</span>

自定义链接图标

[编辑]

通过编辑Special:MyPage/skin.css(仅当前皮肤)或Special:MyPage/common.css(所有皮肤)可添加自定义图标。例如,要为Excel文件添加图标:

#content a[href$=".xls"].external,
#content a[href$=".XLS"].external,
#content a[href$=".xlsx"].external,
#content a[href$=".XLSX"].external {
    background: url("http://upload.wikimedia.org/wikipedia/commons/b/ba/Page_white_excel.png") center right no-repeat; padding-right: 18px;
}

成功更新后,此链接将显示Excel图标:

http://example.org/test.xls

此标记会检测.xls或.xlsx文件扩展名(不区分大小写)。图像宽度必须为16像素。图像链接必须来自http://upload.wikimedia.org。获取此链接的方法:前往文件页面,点击图像打开不含文件描述的版本,然后复制URL。

要移除默认图标,只需添加不含URL的CSS。例如移除安全链接的挂锁图标:

#content a[href ^="https://"].external {
    background: center right no-repeat; 
    padding-right: 18px;
}

要移除所有默认图标,可使用以下CSS:

#content a.external {
    background: none !important;
    padding: 0 !important;
}

参见

[编辑]

注释

[编辑]
  1. ^ 默认PDF图标是通用文档图标,但通过Common.css被替换为