Topic: Open links in new windows

ok to end the debate i have been forced to release this mod, however i don't agree with it tongue

open parser.php
find line 273

    return '<a href="'.$full_url.'">'.$link.'</a>';

replace with

    return '<a href="'.$full_url.'" onclick="window.open(this.href); return false;">'.$link.'</a>';

find line 284

    $img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';

replace with

    $img_tag = '<a href="'.$url.'" onclick="window.open(this.href); return false;"><'.$lang_common['Image link'].'></a>';

i think thats it but i'm not sure, and its valid (even if its not really correct)

2

Re: Open links in new windows

Maybe just add "target" attribute?

return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';

Re: Open links in new windows

no its not valid

Re: Open links in new windows

thanks for this mod connorhd

El Mejor Lugar de la Red - Corporación Azakur4

5

Re: Open links in new windows

Yes, thank you for your work...

6

Re: Open links in new windows

It's a radical mod !!! sad

So ... it's possible to do this ?

in head add

<script type="text/javascript">
         <!--
    function externalLinks() {
        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("rel") == "external")
                anchor.target = "_blank";
                }
            }
        window.onload = externalLinks;
           -->
        </script>

The script searchs on the whole site ... where a rel=external is inside the links.


If javascript is disable, it degrades well ... and it's according about W3C


In code we have

<a href="http://punbb.org" rel="external">The Best Forum, PunBB</a>

In this case, by default, a link has no target ... but by creating a specific BBcode ...

[url-win]http://punbb.org[/url-win]

Or, of course

[url-win=http://punbb.org]PunBB.Org in a New Window[/url]

In this case, it adds in final code rel="external"


.... POSSIBLE ?

7

Re: Open links in new windows

Have you been smoking hashish?

"You start coding. I'll go find out what they want." - Computer Analyst to Programmer

8

Re: Open links in new windows

The problem with this mod is that it prevents users from opening links in new tabs.

Re: Open links in new windows

please don't start that again, i made this mod to stop that go read the half dozen other topics on it

10

Re: Open links in new windows

However Connorhd smile your mod is "extrem" : with your mod, all links become externals ... no ?

Re: Open links in new windows

all posted links become external, if you don't like it make your own mod

Re: Open links in new windows

see what happens when you try to please one group Connorhd, you are chastized by another. wink

~James
FluxBB - Less is more

13

Re: Open links in new windows

Connorhd wrote:

all posted links become external, if you don't like it make your own mod

don't bite please ... mmmmmm after reflexion, I like it .. smile