Test if links are external with jQuery / javascript?

Posted by Matrym on Stack Overflow See other posts from Stack Overflow or by Matrym
Published on 2010-05-26T07:37:25Z Indexed on 2010/05/26 7:41 UTC
Read the original article Hit count: 185

Filed under:
|
|
|

How do I test to see if links are external or internal? Please note:

  1. I cannot hard code the local domain.
  2. I cannot test for "http". I could just as easily be linking to my own site with an http absolute link.
  3. I want to use jQuery / javascript, not css.

I suspect the answer lies somewhere in location.href, but the solution evades me.

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery