Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 03-05-2008, 02:00 PM   #1 (permalink)
Contributing Member
 
gridsix's Avatar
 
Join Date: 03-04-08
Posts: 200
iTrader: 0 / 0%
gridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the rough
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!
gridsix is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 03-05-2008, 02:08 PM   #2 (permalink)
Contributing Member
 
impius's Avatar
 
Join Date: 01-28-08
Posts: 123
iTrader: 0 / 0%
Latest Blog:
None

impius is liked by many
Lightbulb

http://www.htmlcodetutorial.com/link...amsupp_72.html

This is pretty simple...
impius is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-05-2008, 02:13 PM   #3 (permalink)
Contributing Member
 
gridsix's Avatar
 
Join Date: 03-04-08
Posts: 200
iTrader: 0 / 0%
gridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the rough
And that code will automatically replace all external links? It looks like I have to edit each link individually...
gridsix is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-05-2008, 02:17 PM   #4 (permalink)
Contributing Member
 
impius's Avatar
 
Join Date: 01-28-08
Posts: 123
iTrader: 0 / 0%
Latest Blog:
None

impius is liked by many
Ohhhhhh...didnt catch that...I dont think that is possible...would be nice though
impius is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-05-2008, 02:18 PM   #5 (permalink)
Contributing Member
 
gridsix's Avatar
 
Join Date: 03-04-08
Posts: 200
iTrader: 0 / 0%
gridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the rough
Sorry for leaving that detail out...

You sure? seems like a lot of scripts have that built in...
gridsix is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-05-2008, 02:22 PM   #6 (permalink)
Contributing Member
 
impius's Avatar
 
Join Date: 01-28-08
Posts: 123
iTrader: 0 / 0%
Latest Blog:
None

impius is liked by many
I am not positive...but typically you have to call a script from within the link.

I would definetly be interested if someone had a way.
impius is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-06-2008, 12:55 AM   #7 (permalink)
Contributing Member
 
Join Date: 09-03-07
Location: England
Posts: 425
iTrader: 0 / 0%
Latest Blog:
None

Boogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the rough
You could use Javascript to iterate through all the <a href's></a> within the page when it loads. If they are an external link then add the attribute, 'target="_Blank"

Boog's
__________________
Great new 'June' Javascript Framework

June Forums - Innovative JScripting

Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-06-2008, 07:37 AM   #8 (permalink)
Contributing Member
 
gridsix's Avatar
 
Join Date: 03-04-08
Posts: 200
iTrader: 0 / 0%
gridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the rough
Got an example of the code?
gridsix is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-07-2008, 01:32 AM   #9 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 625
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
New-Window Links in a Standards-Compliant World
nasty.web is online now  
Add Post to del.icio.us
Reply With Quote
Old 03-07-2008, 01:43 AM   #10 (permalink)
Contributing Member
 
Join Date: 09-03-07
Location: England
Posts: 425
iTrader: 0 / 0%
Latest Blog:
None

Boogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the roughBoogle is a jewel in the rough
good find, Nasty that's just about what i was thinking, i think that method's better than the one i would have used though!

Boog's
__________________
Great new 'June' Javascript Framework

June Forums - Innovative JScripting

Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-07-2008, 07:32 AM   #11 (permalink)
Contributing Member
 
gridsix's Avatar
 
Join Date: 03-04-08
Posts: 200
iTrader: 0 / 0%
gridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the roughgridsix is a jewel in the rough
That article states that i need to edit every link on the site; am i missing something?

THanks.
gridsix is offline  
Add Post to del.icio.us
Reply With Quote
Old 03-07-2008, 07:44 AM   #12 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 625
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
Quote:
Originally Posted by gridsix View Post
That article states that i need to edit every link on the site; am i missing something?

THanks.
Not neccesarily so. You can change externalLinks function to check href attributes, for example:

Code:
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && (anchor.getAttribute("href").indexOf("http://www.yourdomain.com") == -1)) // anchor.target = "_blank"; } }
nasty.web is online now  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



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

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open a new window in Adsense? minbak Contextual Networks 19 12-01-2007 09:42 AM
blogger, open image in window script? littlephoenix Blogging Forum 2 11-13-2007 02:05 PM
Open browswer window behavior question worldly1 Web Design Lobby 1 07-13-2007 12:57 AM
Open all links in new window Jazzee Coding Forum 18 12-17-2003 03:58 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:18 PM.
© Copyright 2008 V7 Inc