NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Forcing external links to open in a new window

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 03-05-2008, 02:06 PM THREAD STARTER               #1 (permalink)
New Member
Join Date: Mar 2008
Posts: 15
gridsix is an unknown quantity at this point
 



Forcing external links to open in a new window


Anyone know of a way to make all external links on a given site open in a new window? Maybe via css, or the htaccess file?

Thanks much!
__________________
zMogo WebMaster Community
gridsix is offline  
Old 03-05-2008, 02:46 PM   #2 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund
htaccess has no effect over what window links open in.

The best bet would be use PHP's output buffering to 'catch' the output, then find out-going links and rewrite them as such to add the extra tag needed.

I would write some code, but I'm kinda tired.

Dan
Daniel is offline  
Old 03-05-2008, 03:34 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: Mar 2008
Posts: 15
gridsix is an unknown quantity at this point
 



would there be a lot of code? how would i implement it site-wide?

Thanks...
__________________
zMogo WebMaster Community
gridsix is offline  
Old 03-05-2008, 07:45 PM   #4 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,620
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 




You can use the JavaScript, which is attached below
It will convert all external links, and add "target=_blank" for each external link, automatically on body "onload".

Kurniawan.
Attached Files
File Type: txt html.txt (1.2 KB, 10 views)
__________________
Last edited by xrvel; 03-07-2008 at 08:14 PM.
xrvel is offline  
Old 03-07-2008, 01:04 PM   #5 (permalink)
NamePros Regular
 
Zubair1's Avatar
Join Date: Mar 2005
Posts: 912
Zubair1 is just really niceZubair1 is just really niceZubair1 is just really niceZubair1 is just really niceZubair1 is just really nice
 


AIDS/HIV
If you don't have a problem, it can also be done with PHP by making a function
let me know if you want that and i'll have it done for you

but do note you will have to add links using that function like this for example if you want to add a new link pointing to msn.com you would have to do it this way.

Code:
<?php add_link("http://www.msn.com/"); ?>
__________________
Live Support : Zubair11 [at] hotmail.com
Free SEO Directory! || Free Online TV || Tech Blog
Web Design & Web Development Services || Reliable Web Hosting
Zubair1 is offline  
Old 03-07-2008, 08:09 PM   #6 (permalink)
NamePros Regular
 
monaco's Avatar
Join Date: Jul 2005
Location: Tucson, AZ
Posts: 689
monaco will become famous soon enough
 



Just edit your external links to use target=_blank as an attribute to the a tag. If the links are put there by you, do it manually, if they're being put there by a script, edit the script.
__________________
My Website | My Blog
monaco is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 10:16 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger