Internal links in new tabs

Discussions about the phpBB2 Forum. How to get the best from this powerful script.

Moderator: Moderators

Internal links in new tabs

Postby The_Wizard » Sun Feb 01, 2009 12:41 am

How can i open internal links in new tabs?

And one more question
I found somewhere on this forum how to open external links in new tabs, but google ads link dont open in new tabs. is there something i can do to open google ads in new tabs?

Code: Select all
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
// Open external links in new window in a XHTML 1.x compliant way.
function nw_external() {
   var current_domain = document.domain;
   if (!current_domain || !document.getElementsByTagName) return;
   var hrefels = new Array;
   var hrefelslen = 0;
   var hrefinner = '';
   hrefels = document.getElementsByTagName("a");
   hrefelslen = hrefels.length;
   for (var i = 0; i < hrefelslen; i++) {
      hrefinner = hrefels[i].innerHTML.toLowerCase();
      if ( (hrefels[i].href == '') || (hrefinner.indexOf('<a') >= 0) || (hrefels[i].href.indexOf(current_domain) >= 0) ) {
         continue;
      }
      hrefels[i].onclick = function () { window.open(this.href); return false; };
   }
}
onload_functions.push('nw_external()');
// www.phpBB-SEO.com SEO TOOLKIT END
The_Wizard
 
Posts: 17
Joined: Wed Dec 31, 2008 9:38 am

Advertisement

Postby SeO » Sun Feb 01, 2009 10:10 am

No, there is nothing you can do about AdSense link targets, since it's part of the AdSense TOS that you won't modify the ads code in any manner.
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm

Postby The_Wizard » Sun Feb 01, 2009 12:07 pm

ok.

how about internal links?
The_Wizard
 
Posts: 17
Joined: Wed Dec 31, 2008 9:38 am

Postby SeO » Mon Feb 02, 2009 10:47 am

Oh, to open all links in new window (including the internal ones, you can just replace :
Code: Select all
      if ( (hrefels[i].href == '') || (hrefinner.indexOf('<a') >= 0) || (hrefels[i].href.indexOf(current_domain) >= 0) ) {


with :
Code: Select all
      if ( (hrefels[i].href == '') || (hrefels[i].href.indexOf('javascript') >=0 ) || (hrefinner.indexOf('<a') >= 0) ) {


In this I restored the latest code from here too ;)
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm

Postby The_Wizard » Mon Feb 02, 2009 12:21 pm

thx :)
The_Wizard
 
Posts: 17
Joined: Wed Dec 31, 2008 9:38 am


Return to phpBB2 Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests