Click to See Complete Forum and Search --> : open external links in new window


babettelafox
02-07-2006, 11:46 PM
i've been searching for a script that would distinguish between internal and external links, and then open only external links in a new window. any thoughts on this matter would be greatly appreciated.

thanks -
carrie

CrazyMerlin
02-08-2006, 12:57 AM
ok, generally but not rule of thumb... most internal links are relative so they be like

../forms/user_submit.htm

whereas external links will be

http://thisPlace.com/forms/user_submit.htm

this is by far not always true. Using this method you can check the substr(1,4) and see it it contains a protocol

maybe a start

cbrookes
02-08-2006, 02:59 AM
Where the urls are all full links (http://...) then you can 'split()' the string and compare the hostname part with location.hostname.