Total Users Online: 43 üye, 15 guest | Tarih/Saat: 2020-01-20 15:43
OPEN EXTERNAL URLS IN NEW WINDOW
A no-plugin HOWTO
You probably know that there is a plugin which makes external links open in new window. If it doesn't work for you or you don't want to add yet one more plugin to your Seditio, I can help with no-plugin version of ExtLinks. The only requirement for your visitors is JavaScript >= 1.2 enabled.

All you need is edit your skins/Your_Skin/header.tpl. Add the following script to the <head> section of the templates's HTML:
JAVA:
<script language="javascript" type="text/javascript">

// Open external links in new window

function extLinks2() {

    var extl = document.getElementsByTagName('a');

    var re = new RegExp('^http://' + location.host, 'i');

    for(var i = 0; i < extl.length; i++) {

        if(extl.href.match('http://') && !re.test(extl.href)) {

            extl.target = '_blank';

            extl.className += ' external';

        }

    }

}



</script>

Then there are 2 ways to enable it:
1. Add it to your onLoad attribute of <body> tag, just like:
Kod:
<body onLoad="extLinks2()">

or if you already have onLoad handlers
Kod:
<body onLoad="myLoadFunction(); extLinks2();">

2. Or you may add the following code to the script:
Kod:
var oldonload = window.onload;
window.onload = function() {
    oldonload();
    extLinks2();
}

Sometimes the above solution doesn't work properly with hover images and some jQuery code. If you use jQuery, I can offer you another solution:
Kod:
<script language="javascript" type="text/javascript">
$(document).ready( function() {
    var extl = document.getElementsByTagName('a');
    var re = new RegExp('^http://' + location.host, 'i');
    for(var i = 0; i < extl.length; i++) {
        if(extl[i].href.match('http://') && !re.test(extl[i].href)) {
            extl[i].target = '_blank';
            extl[i].className += ' external';
        }
    }
} );
</script>

Henüz yorum yapılmamıştır.
OPEN EXTERNAL URLS IN NEW WINDOW
Author: Kaan
Date: 2011-11-27 14:17
Comments: (0)
Benzer SayfalarYorum
Greybox Smart Window0
Open Inviter0
Open Comments2
REMOVING PHPSESSID FROM URLS0
 
Powered by Seditio © 2009-2012 All Rights Reserved