简体   繁体   中英

Open a page in new tab and refresh the old page(Struts2 + javascript)

I am having one hidden form

<form name="printPhysicalAnn" id="printPhysicalAnn" method="post" target='_new'>

        <s:hidden name="aId" id="aId"/>
        <s:hidden name="ty" id="ty" value="physical possession"/>
        <input type="hidden" name="appId" id="appIdsss" value="${appId}"/>
    </form>

Which is being submitted through javascript. The resultant page opens in new tab. I want to refresh the parent tab after this form is submitted. The following javascript code works perfectly fine all the browsers except Google Chrome.

var r = confirm("Are you sure you want to generate certificate");
     if (r == true) {
        document.printPhysicalAnn.action = root+"/RES/ann2HsiidcPhysical";
         document.forms['printPhysicalAnn'].submit();
         document.location =window.location;
     }

Instead of

document.location =window.location;

Use

location.reload();

or this if you want to bypass cache

location.reload(true);

Edit :

Your form isn't submitting because _new isn't a valid target. Use _blank if you want it to open in a new tab/window

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM