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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题