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条)

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题