Editing
Open a link in mediawiki to a new window
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
<< [[MediaWiki]] 以新視窗方式開啟MediaWiki外站鏈結 {{Wiki version| wiki_engine=MediaWiki | version=1.11.0 }} == 安裝方式 == * 嵌入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> 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 </pre> * 回到有外站鏈結的wiki頁面,請先強迫更新瀏覽器的快取檔案 ({{IE}}或{{Fx}}: 請按Ctrl+F5),開新視窗才會生效。 資料來源: Yank, Kevin (2003). [http://www.sitepoint.com/article/standards-compliant-world New-Window Links in a Standards-Compliant World] 原本Yank的script是針對rel=external,此處則針對class="external text"進行宣告。 == 其他方法 == * [http://www.jimbojw.com/wiki/index.php?title=Popup_links_in_MediaWiki_to_new_window Popup links in MediaWiki to new window - Jimbojw.com] ** 缺點是需要針對每個外站鏈結設定 class="pops" <pre> <span class="pops">http://www.google.com/</span> </pre> * 檢索策略: mediawiki "new window" 其他wiki * [[Open new window of DokuWiki syntax]] [[Category:MediaWiki]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Fx
(
edit
)
Template:IE
(
edit
)
Template:Wiki version
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information