[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 03-05-2008, 01:06 PM   #1 (permalink)
New Member
 
Join Date: Mar 2008
Posts: 15
0.00 NP$ (Donate)

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, 01:46 PM   #2 (permalink)
Danltn.com
 
Daniel's Avatar
 
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
13.51 NP$ (Donate)

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, 02:34 PM   #3 (permalink)
New Member
 
Join Date: Mar 2008
Posts: 15
0.00 NP$ (Donate)

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, 06:45 PM   #4 (permalink)
i love automation
 
xrvel's Avatar
 
Join Date: Nov 2007
Posts: 1,409
987.78 NP$ (Donate)

xrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud of


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 07:14 PM.
xrvel is offline  
Old 03-07-2008, 12:04 PM   #5 (permalink)
NamePros Regular
 
Zubair1's Avatar
 
Join Date: Mar 2005
Posts: 874
159.45 NP$ (Donate)

Zubair1 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 Games and Songs || eBloggy.net
Zubair.info || Mixcat Interactive
Zubair1 is offline  
Old 03-07-2008, 07:09 PM   #6 (permalink)
NamePros Regular
 
monaco's Avatar
 
Join Date: Jul 2005
Location: Tucson, AZ
Posts: 695
314.80 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 03:02 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85