ok is there a php code i can put in my page so all links that arent of my domain will open in a new tab like "_blank"??? i already my my site and have alot of links in it and i dotn wanna go bank and add "_blank"...is there a php code i can put so it can make all external links or at least links of a certain domain open in new tab!?
that makes all links on my page open in new tab....can you modify that code so only links that arent of my sites domain open in new tab?
You need Javascript for that. PHP is on the server and can't do stuff like that on the client's side.
PHP is server side language as nico_swd said, so you can not directly affect on client's browser. The only way to do that is by using HTML, JS or maybe Flash (I'm not working with it so I'm not sure). The easyest way to do it is by HTML: <a href="site address" target="_blank">Site description</a> HTML: I guess you want you code to be W3C standard's valid, so if you are using in HTML header (DTD) strict change it to transitional, because strict doesn't support target. Edit: I have reread you post again, and I have notice I didn't understand , so sorry about this. If your page links are generated from PHP, and you are using some template engine (but there isn't need to have it), then you can do it. Just explain how your page works and we will try to help you Best regards, Ivan
i have a wordpress blog, and wordpress is like all php...ive made several post with links in the them and they all when clicked on open in same window, i need a code that i can put at top of page so that all those links i posted that lead to other sites thats arent my own can be opened in a new tab. i know this must be possible becuase when i put nico's html code, <base target="_blank" /> Code (markup): , at top of my index page its scans through all the whole page and makes all links open in new tab, so there must be a code that can make all external links open in new tab!
I think it's better to replace it directly in DB, than using JS for that. Just write a regex code for that, and replace posts in DB If you want, that can be done also in JS. You will need to get all "a" tags, and do check for every tag if it isn't your domain (with regex to get full domain, not a page link), then set target to "_blank". BTW <base target="_blank" /> Code (markup): isn't allowed by AdSense, because it will open ads in new page. Ivan
found solution! http://www.inverudio.com/programs/WordPressBlog/NewTabWindowTargetBlankPlugin.php i knew you could do it with php!