Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect previous page using javascript

How to redirect previous page after redirect to previous page. After form submission i am redirect form to thank you page but after sometimes i want redirect previous page.

Below is the code i am using

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
    //location = 'abc.com1/thank-you/';
     if ( '17615' == event.detail.contactFormId ) { 
     } 
    else if( '19110' == event.detail.contactFormId ){
        location = 'abc.com1/thank-you-broucher/';
    }
    else {
         location = 'abc.com1/thank-you/';
     }
}, false );
</script>

after location redirect i want again redirect to my first original page.

Anyone have idea then let me know

like image 385
Praff Avatar asked Feb 17 '26 00:02

Praff


1 Answers

use history.back

window.history.back();
like image 189
ali ahmad Avatar answered Feb 18 '26 13:02

ali ahmad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!