I'm using menu minipanels to display a custom menu. It consists of external links to be opened in a new tab/window. To keep the code xhtml strict valid, I used a class = "blank" for each link and a javascript code:

<?php
externalLinks
function () {
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 ("class") == "blank")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
?>

This code works correctly for all links in the website but does not work for links in the minipanel menu. The reason I do not know, but it could be due to a problem of delayed loading of the mini panel or a cache problem. In fact, when I empty the drupal cache, target = "_blank" appears, but when reloading the page, it disappears!

Any suggestion is welcome.

Comments

Alex72RM’s picture

Status:Active» Needs review

I solved by myself.

I needed to add:

    $('a.blank', context).attr('target', '_blank');

after

  $('ul li a.menu-minipanel').each(function() {

into js/menu_minipanels.js file.

The solution was based upon Drupal.behaviors, because window.onload doesn't apply anymore with Drupal 6.x.

DamienMcKenna’s picture

The forthcoming v6.x-1.3 release will support a new field to specify the target.

DamienMcKenna’s picture

Status:Needs review» Postponed (maintainer needs more info)

Doh. Sorry, the "target" field(s) in the latest version are for something else.

I'm not intending to add this as an option in the module as it feels like unnecessary bloat. Maybe instead you could use the new custom JavaScript callbacks to do it in the latest version, e.g.:

MenuMiniPanels.setCallback('onRender', function(qTip, event, content) {}

Please see the API.txt for more details. If you happen to work out how to do it via the callbacks, please post your code here and I'll be happy to add it to the API.txt file for others to benefit from. Thanks in advance :)