{"id":258,"date":"2012-02-10T12:15:28","date_gmt":"2012-02-10T12:15:28","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=258"},"modified":"2026-03-09T18:02:48","modified_gmt":"2026-03-09T18:02:48","slug":"redirect","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/page_control\/redirect","title":{"rendered":"Redirecting"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Redirect To A New Page<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Don&#8217;t keep the current page in History (Back button won&#8217;t return to it)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\n  window.location.replace(\"https:\/\/somedomain.com\");\n\n  \/\/window.location.replace(\"\/some_page?MyArg1=' + encodeURIComponent(MyArg1Value) );\n&lt;\/script><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Keeping the current page in history (for Back button)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;\n  window.location = \"https:\/\/somedomain.com\";\n\n  \/\/window.location = \"\/some_page?MyArg1=' + encodeURIComponent(MyArg1Value);\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Redirect With POST Data Using A Hidden Form<\/h4>\n\n\n\n<p>Include the hidden form with the values you want to send on the page:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- ----------------------------------------------- --&gt;\n&lt;!-- HIDDEN FORM AUTO SUBMITTED ON UPLOAD COMPLETION --&gt;\n&lt;!-- ----------------------------------------------- --&gt;\n&lt;form id=\"form_upload_complete\" name=\"form_upload_complete\" method=\"post\" action=\"http:\/\/www.mydomain.com\/successful_upload.php\"&gt;\n   &lt;input type=\"hidden\" name=\"field1\" value=\"some value\" \/&gt;\n   &lt;!-- etc... --&gt;\n&lt;\/form&gt;<\/code><\/pre>\n\n\n\n<p>Then in your javascript use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>document.forms&#91;\"form_upload_complete\"].submit();<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Open page in a new browser tab<\/h4>\n\n\n\n<p>Use <code>window.open()<\/code> instead of assigning to <code>window.location<\/code>()<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;\n  window.open(\"https:\/\/somedomain.com\", \"_blank\");\n&lt;\/script&gt;\";<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Go Back To Previous Page<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>history.go(-1);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Redirect To A New Page Don&#8217;t keep the current page in History (Back button won&#8217;t return to it) Keeping the current page in history (for Back button) Redirect With POST Data Using A Hidden Form Include the hidden form with the values you want to send on the page: Then in your javascript use Open [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87,67,47],"tags":[],"class_list":["post-258","post","type-post","status-publish","format-standard","hentry","category-links-jquery-mobile","category-links-javascript","category-page_control"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":14,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":4403,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/258\/revisions\/4403"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}