{"id":2658,"date":"2018-03-20T08:57:40","date_gmt":"2018-03-20T07:57:40","guid":{"rendered":"http:\/\/www.capri-soft.de\/blog\/?p=2658"},"modified":"2018-03-20T08:59:42","modified_gmt":"2018-03-20T07:59:42","slug":"javascript-read-url-get-parameter-from-the-browsers-address-bar-that-have-been-passed-commited","status":"publish","type":"post","link":"https:\/\/www.capri-soft.de\/blog\/?p=2658","title":{"rendered":"Javascript: Read URL GET Parameter from the browsers address bar that have been passed \/ commited"},"content":{"rendered":"<h1>Problem<\/h1>\n<p>A javascript should read the browsers address bar to get GET \u00dcarameters that have been appended to the adress bar.<\/p>\n<h1>Approach &#8211; Ansatz<\/h1>\n<p>Usage of decodeURIComponent<\/p>\n<h1>Solution<\/h1>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar getUrlParameter = function getUrlParameter(sParam) {\r\n\tvar sPageURL = decodeURIComponent(window.location.search.substring(1)),\r\n\t\tsURLVariables = sPageURL.split('&amp;'),\r\n\t\tsParameterName,\r\n\t\ti;\r\n\r\n\tfor (i = 0; i &lt; sURLVariables.length; i++) {\r\n\t\tsParameterName = sURLVariables&#x5B;i].split('=');\r\n\r\n\t\tif (sParameterName&#x5B;0] === sParam) {\r\n\t\t\treturn sParameterName&#x5B;1] === undefined ? true : sParameterName&#x5B;1];\r\n\t\t}\r\n\t}\r\n};\r\n\r\nvar myMap = getUrlParameter(&quot;map&quot;);\r\nif (myMap) {\r\n\tdiagramType = myMap;\r\n}\r\n<\/pre>\n<p>You can call now the script like this:<br \/>\nhttp:\/\/webseite.html?map=Test<\/p>\n<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href=https%3A%2F%2Fwww.capri-soft.de%2Fblog%2F%3Fp%3D2658&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden; width:450px;margin-top:5px;\"><\/iframe>","protected":false},"excerpt":{"rendered":"<p>Problem A javascript should read the browsers address bar to get GET \u00dcarameters that have been appended to the adress bar. Approach &#8211; Ansatz Usage of decodeURIComponent Solution var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split(&#8218;&amp;&#8216;), sParameterName, i; for (i = 0; i &lt; sURLVariables.length; i++) { sParameterName = sURLVariables&#x5B;i].split(&#8218;=&#8216;); &hellip; <a href=\"https:\/\/www.capri-soft.de\/blog\/?p=2658\" class=\"more-link\"><span class=\"screen-reader-text\">Javascript: Read URL GET Parameter from the browsers address bar that have been passed \/ commited<\/span> weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[30],"tags":[],"class_list":["post-2658","post","type-post","status-publish","format-standard","hentry","category-javascript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4yGeN-GS","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2658"}],"version-history":[{"count":2,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2658\/revisions"}],"predecessor-version":[{"id":2661,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2658\/revisions\/2661"}],"wp:attachment":[{"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.capri-soft.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}