How Can I Refresh A Form Page After The Form Submits To _blank? November 23, 2023 Post a Comment I have an HTML form which targets _blank. I would like the page that form is on to reload after submitting. So here's some sample markup: Solution 1: Not sure why window.location.reload() doesn't work. I think it should. However, this does seem to work:onsubmit="setTimeout(function () { window.location.reload(); }, 10)"CopySolution 2: There are two ways to do this, one that you may not want to hear about.FIRST:In the form init tag, if you set action="" then the form will submit to the same page (to itself). <formaction=""method="post">CopyThis allows you to add server-side code to the top of the page, like this (using PHP, for example):<?phpIf (empty($_POST)===false) { //server side scripting to handle the submitted form }else{ ?>//HTML to create/show the page with form for user input<?php//Close the if statement } ?>CopySECOND:Use AJAX (javascript or jQuery) to "submit" the form, and then -- in the AJAX function's callback -- carry on with whatever changes you want to make to the page, including redirecting to a new page.Baca JugaDoes Submit() Function Has A Callback?Greasemonkey Script To Append Text, To A Form, When Submitted With Ajax?Javascript Redirect Based On Option SelectedSolution 3: It should work if a callback is passed to the onsubmit event attribute. For example,(Traditional anonymous function)onsubmit="function() {location.reload()}"Copyor(Arrow function) onsubmit="() => location.reload()"CopySolution 4: location.refresh(true); Copywill help Share You may like these postsDisable Ios Overscroll But Allow Body ScrollingReload Other Page When Click Button "refresh"Change The Size Of Div By Selecting Value From The DropdownSelecting Multiple Radio Buttons With Alert Post a Comment for "How Can I Refresh A Form Page After The Form Submits To _blank?"
Post a Comment for "How Can I Refresh A Form Page After The Form Submits To _blank?"