{"id":4368,"date":"2020-12-17T10:47:34","date_gmt":"2020-12-17T09:47:34","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=4368"},"modified":"2022-07-25T08:35:41","modified_gmt":"2022-07-25T07:35:41","slug":"javascript-reload-page","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/javascript-reload-page\/","title":{"rendered":"Javascript Reload page"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">function getQueryParams(qs: string) {\n    const params: { [key: string]: any } = {};\n    qs = qs.split(\"+\").join(\" \");\n    let tokens;\n    const re = \/[?&amp;]?([^=]+)=([^&amp;]*)\/g;\n    \/\/ eslint-disable-next-line no-cond-assign\n    while (tokens = re.exec(qs)) {\n        params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);\n    }\n    return params;\n}\n\nfunction createQuery(data: any) {\n    const c = encodeURIComponent;\n    const cv = (v: any) => v &amp;&amp; v.toISOString ? v.toISOString() : v;\n    return \"?\" + Object.keys(data).map(k => `${c(k)}=${c(cv(data[k]))}`).join(\"&amp;\");\n}\n\nfunction getRefreshUrl(l: Location): string {\n    const query = getQueryParams(l.search);\n    query._ = String(Math.random()).slice(2);\n    return l.origin + l.pathname + createQuery(query) + l.hash;\n}\n\nconst url = getRefreshUrl(window.location);\nconsole.log(url)\nwindow.location.href = url;\n<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[5,4,1],"tags":[],"class_list":["post-4368","post","type-post","status-publish","format-standard","hentry","category-javascript","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=4368"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4368\/revisions"}],"predecessor-version":[{"id":4369,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4368\/revisions\/4369"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=4368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=4368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=4368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}