Anchor Href is Local?


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // If href does not contain "http" at the beginning, or it's an absolute, but local href, must be local.
  2. var isLocal = ( !/^(http)/.test(href) ) || ( href.indexOf(location.hostname) > -1 );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.