I want to open All external link into new window/tab through php without touching every external link code. and i don't want to this without target="blank".
I can do this through javascript but i want to know if there is a PHP solution.
I want to open All external link into new window/tab through php without touching every external link code. and i don't want to this without target="blank".
I can do this through javascript but i want to know if there is a PHP solution.
Not sure if I got this one right, but if you're looking for a JS alternative to "target=blank" then this one works and is xhtml valid:
onclick="window.open(this.href, '_blank'); return false;"
This job cannot be done with PHP. PHP is on the server side while your problem requires interaction with the client. This is a classical thing you'd use javascript for.
In case you use JQuery things become extremely simple:
// pretend you have links in your page <a href="link.htm" rel="external">Link</a>
// please note that the rel-value can be chosen at will
$(document).ready(function(){
$('a[rel="external"]').click(function() {
window.open(this.href, '_blank');
return false;
});
});