{"id":111,"date":"2005-08-29T16:19:15","date_gmt":"2005-08-29T14:19:15","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2005\/08\/29\/the-difference-between-href-and-getattributehref-in-javascript\/"},"modified":"2006-04-14T16:30:56","modified_gmt":"2006-04-14T14:30:56","slug":"the-difference-between-href-and-getattributehref-in-javascript","status":"publish","type":"post","link":"http:\/\/www.maratz.com\/blog\/archives\/2005\/08\/29\/the-difference-between-href-and-getattributehref-in-javascript\/","title":{"rendered":"The Difference Between <em>href<\/em><br \/>and <em>getAttribute(&#8216;href&#8217;)<\/em> in JavaScript"},"content":{"rendered":"<p>For the HTML code <code>&#60;a id=\"aboutLink\" href=\"\/about\/\">about&#60;\/a><\/code>, the <code>document.getElementBy Id('aboutLink').href<\/code> will return the full URL of the linked resource, for example <code>http:\/\/somesite.com\/about\/<\/code>.<\/p>\n<p>If you want to get the exact value of the <code>href<\/code> attribute, you\u2019d use <code>document.getElementById('aboutLink').getAttribute('href')<\/code>, which returns <code>\/about\/<\/code>. Yea, right &#8211; not in IE and Opera (both Win and Mac). <a href=\"http:\/\/webdesign.maratz.com\/lab\/DOM_href_demo\/\">See demo<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For the HTML code &#60;a id=&#8221;aboutLink&#8221; href=&#8221;\/about\/&#8221;>about&#60;\/a>, the document.getElementBy Id(&#8216;aboutLink&#8217;).href will return the full URL of the linked resource, for example http:\/\/somesite.com\/about\/. If you want to get the exact value of the href attribute, you\u2019d use document.getElementById(&#8216;aboutLink&#8217;).getAttribute(&#8216;href&#8217;), which returns \/about\/. Yea, right &#8211; not in IE and Opera (both Win and Mac). See demo.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/111"}],"collection":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=111"}],"version-history":[{"count":0,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/111\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}