Open a link in mediawiki to a new window: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 7: | Line 7: | ||
== 安裝方式 == | == 安裝方式 == | ||
* 使用具管理者權限的帳號編輯[[MediaWiki:Common.js]] (另一嵌入Javascript方法,則是修改面版檔案 ex: {MediaWiki}/skins/MonoBook.php ) | * 嵌入Javascript | ||
** 使用具管理者權限的帳號編輯[[MediaWiki:Common.js]] (另一嵌入Javascript方法,則是修改面版檔案 ex: {MediaWiki}/skins/MonoBook.php ) | |||
** 或 使用者自行編輯 User:[your name]/[your skin].js (需該MediaWiki站啟用[http://www.mediawiki.org/wiki/Manual:%24wgAllowUserJs $wgAllowUserJs]功能,預設值是關閉的。) | |||
<pre> | <pre> | ||
Revision as of 00:27, 14 February 2008
<< MediaWiki
以新視窗方式開啟MediaWiki外站鏈結
| MediaWiki | v.1.11.0+ |
安裝方式
- 嵌入Javascript
- 使用具管理者權限的帳號編輯MediaWiki:Common.js (另一嵌入Javascript方法,則是修改面版檔案 ex: {MediaWiki}/skins/MonoBook.php )
- 或 使用者自行編輯 User:[your name]/[your skin].js (需該MediaWiki站啟用$wgAllowUserJs功能,預設值是關閉的。)
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
//anchor.getAttribute("rel") == "external")
anchor.getAttribute("class") == "external text")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
//from_http://www.sitepoint.com/article/standards-compliant-world
資料來源: Yank, Kevin (2003). New-Window Links in a Standards-Compliant World 原本Yank的script是針對rel=external,此處則針對class="external text"進行宣告。
其他方法
- Popup links in MediaWiki to new window - Jimbojw.com
- 缺點是需要針對每個外站鏈結設定 class="pops"
<span class="pops">http://www.google.com/</span>
- 檢索策略: mediawiki "new window"
其他wiki