I'm trying to find something that will make outgoing links redirect first, so if the page links to http://google.com it goes to http://site.com/bye.php?go=http://google.com first without me having to add the whole redirection url by hand. I'm preferably looking for something in Php but javascript is fine, this is what I could come up with but it didn't work:
Code:<script type="text/javascript"> function replaceWords() { // ***add the words or fragments you wish to replace below var oldWords = new Array( "http://", "https://" ); // *** add the replacing words or fragments below var newWords = new Array( "http://site.com/bye.php?go=http://", "https://site.com/bye.php?go=http://" ); allTableData = document.getElementsByTagName('td'); allTableHeaders = document.getElementsByTagName('th'); var collections = new Array(allTableData,allTableHeaders); for (var k = 0 ; k < collections.length ; ++k ) { for (var i = 0 ; i < collections[k].length ; ++i ) { if (collections[k][i].innerHTML.indexOf('TABLE') == -1) { for ( var n = 0 ; n < oldWords.length; ++n ) { var indx = collections[k][i].innerHTML.indexOf(oldWords[n]) while (indx != -1) { var replacement = ''; indx = collections[k][i].innerHTML.indexOf(oldWords[n]); replacement = collections[k][i].innerHTML.replace(oldWords[n], newWords[n]); collections[k][i].innerHTML = replacement; break; } } } } } } replaceWords(); </script>



Reply With Quote
Bookmarks