dsfs23434 2012-04-02 19:41
浏览 47
已采纳

MediaWiki中的不同链接

I am using MediaWiki version 1.18.2, I know that if I want my links to open in new tab/window I have to set up

$wgExternalLinkTarget = '_blank';

in LocalSettings.php

I am creating the links like this

[http://www.google.com/ google]

is there a way that I can make some links open in the same tab/window and others in new tab/window with the same settings in LocalSettings.php?

  • 写回答

2条回答 默认 最新

  • dpb75177 2012-04-03 14:05
    关注

    Mediawiki allows you to wrap html tags around links; you can set the default to not open a new tab/window, and for those you do want to have in a new window, wrap in a different class:

    <span class="new-win">[http://google.com google]</span>
    

    Then you can use JavaScript to make all the "new-win"-wrapped links open a new window; add this to your Common.js script:

    jQuery( document ).ready( function( $ ) { 
      $(".new-win a").click(function(event) {
        event.preventDefault(); // Keep from following standard href of link
        new_win = window.open($(this).attr('href'), 'offsite_popup') // Pop up a window to that URL
        if (window.focus) { new_win.focus() } // Give it focus if possible
      });
    });
    

    EDIT: Modified for user's intent

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效