{"id":629,"date":"2011-08-25T16:20:03","date_gmt":"2011-08-25T14:20:03","guid":{"rendered":"http:\/\/www.tobiasholmberg.com\/blogg\/?p=629"},"modified":"2011-08-25T16:20:04","modified_gmt":"2011-08-25T14:20:04","slug":"javascript-encodingdecoding-aao-korrekt-ur-url","status":"publish","type":"post","link":"https:\/\/www.tobiasholmberg.com\/blogg\/2011\/08\/25\/javascript-encodingdecoding-aao-korrekt-ur-url\/","title":{"rendered":"Javascript -Encoding\/Decoding \u00c3\u00a5\u00c3\u00a4\u00c3\u00b6 korrekt ur URL"},"content":{"rendered":"<h2>H\u00c3\u00a4mta \u00c3\u00a5\u00c3\u00a4\u00c3\u00b6 korrekt ur URL med hj\u00c3\u00a4lp av Javascript<\/h2>\n<p>F\u00c3\u00b6r att tolka \u00c3\u2026\u00c3\u201e\u00c3\u2013 korrekt ur en URL s\u00c3\u00a5 kan du anv\u00c3\u00a4nda dig utav f\u00c3\u00b6ljande funktioner som finns i Javascript.<\/p>\n<h3>H\u00c3\u00a4mta v\u00c3\u00a4rde fr\u00c3\u00a5n URL med javascript<\/h3>\n<p><code>function getUrlVars()<br \/>\n{<br \/>\nvar vars = [], hash;<br \/>\nvar hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');<br \/>\nfor(var i = 0; i &lt; hashes.length; i++)<br \/>\n{<br \/>\nhash = hashes[i].split('=');<br \/>\nvars.push(hash[0]);<br \/>\nvars[hash[0]] = hash[1];<br \/>\n}<br \/>\nreturn vars;<br \/>\n}<\/code><\/p>\n<p>var str = getUrlVars()[&#8221;u&#8221;];&gt;<\/p>\n<h3>H\u00c3\u00a4mta v\u00c3\u00a4rde ur URL med Javascript:<\/h3>\n<p>Med funktionen\u00c2\u00a0decodeURI(str);<\/p>\n<p>Exempel: Ume%E5 blir Ume\u00c3\u00a5<br \/>\nMed funktionen\u00c2\u00a0encodeURI(str);<\/p>\n<p>Exempel: Ume\u00c3\u00a5\u00c2\u00a0\u00c2\u00a0blir Ume%E5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>H\u00c3\u00a4mta \u00c3\u00a5\u00c3\u00a4\u00c3\u00b6 korrekt ur URL med hj\u00c3\u00a4lp av Javascript F\u00c3\u00b6r att tolka \u00c3\u2026\u00c3\u201e\u00c3\u2013 korrekt ur en URL s\u00c3\u00a5 kan du&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[479,485],"tags":[487,491,493,490,492,489,486,488],"_links":{"self":[{"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/posts\/629"}],"collection":[{"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/comments?post=629"}],"version-history":[{"count":2,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/posts\/629\/revisions"}],"predecessor-version":[{"id":631,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/posts\/629\/revisions\/631"}],"wp:attachment":[{"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/media?parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/categories?post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tobiasholmberg.com\/blogg\/wp-json\/wp\/v2\/tags?post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}