Hello everybody!

I have successfully installed the shadowbox module and (nearly) everything is working.
Pictures are handled automatically and also a combination of the video module, views and shadowbox is doing fine.
BUT now I'm trying to open a YouTube video as a hyperlink. The shadowbox is playing the video as I want it to but also a second tab is opening (youtub.com).

What I'm doing wrong?

(sry for my bad english)

Thank you for your help and greets from Austria!

Comments

manfer’s picture

I suppose youtub.com is a typographic error.

Can you provide a link to see the problem?

tchibo’s picture

Shure!
http://tinyurl.com/3lkolm7
Klick on the herlink "Test"

Greets

manfer’s picture

Your problem comes from a javascript code that force external links to be opened in a new tab.

I'm not sure if it is exactly External New Tab

If it can be configured to exclude some links, you should exclude youtube links.

manfer’s picture

Yes confirmed it is that one and it does not have a way to exclude links, only to exclude paths. The feature you would need is to exclude links not paths, so in the path were your youtube links reside, the rest of external links are opened in new tabs if that is what you want.

Your solution is to disable that module or hack it. For example you can hack its external.js file from:

// $Id: external.js,v 1.8 2010/03/22 19:12:55 mcrittenden Exp $
Drupal.behaviors.external = function(context) {
  // Open external links in new tabs.
  $("a[href^=http://]", context).each(function() {
    if(this.href.toLowerCase().indexOf(location.hostname) == -1) {
      $(this).click(externalNewWindow);
    }
  });
  // If the setting is enabled, open PDFs in new tabs.
  if (Drupal.settings.externalpdf) {
    $("a[href*=.pdf]", context).each(function() {
        $(this).click(externalNewWindow);
    });
  };
  // Open any links with class="newtab" in new tabs
  $("a.newtab", context).click(externalNewWindow);

  // Utility function that does the work.
  function externalNewWindow() {
    window.open(this.href);
    return false;
  }
}

to:

// $Id: external.js,v 1.8 2010/03/22 19:12:55 mcrittenden Exp $
Drupal.behaviors.external = function(context) {
  // Open external links in new tabs.
  $("a[href^=http://]", context).each(function() {
    var pattern = /^http:\/\/(www\.)?youtube.com\/.*$/;
    if (pattern.test(this.href.toLowerCase())) return;
    if(this.href.toLowerCase().indexOf(location.hostname) == -1) {
      $(this).click(externalNewWindow);
    }
  });
  // If the setting is enabled, open PDFs in new tabs.
  if (Drupal.settings.externalpdf) {
    $("a[href*=.pdf]", context).each(function() {
        $(this).click(externalNewWindow);
    });
  };
  // Open any links with class="newtab" in new tabs
  $("a.newtab", context).click(externalNewWindow);

  // Utility function that does the work.
  function externalNewWindow() {
    window.open(this.href);
    return false;
  }
}

(I can't highlight this code because php tag does not show the pattern correctly)

But the problem will arise again when you include any other external link you don't want to be opened in a new tab: a vimeo video, an external flash video, ....

tchibo’s picture

Thank you sooo much!
Now it works! Thank you!!!

manfer’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.