http://d.hatena.ne.jp/hasegawayosuke/20141030/p1 code: var elm = document.createElement( "a" ); elm.setAttribute( "href", pattern ); console.log( pattern, elm.protocol, elm.getAttribute( "href", 4 ) ); result: upper row is elm.protocol, lower row is elm.getAttribute( "href" ) patternhttp://a https://a /a a javascript:a vbscript:a a: a:a ftp:a ftp://a mailto:a : /\aa \/aa