I’ve noticed that this topic has been asked about by many people and I thought I’d offer up what I did to eliminate this problem.
For those not familiar with this issue, when you create an InfoPath form and create Submit and Cancel buttons, it is likely you want the Cancel operation to redirect or return you to your originating page. Some folks want to display a "Thank you" page after a submit and then return to their originating page. While you can do this with scripting, such as JavaScript found here, I think I have a simpler method that doesn’t require you write any custom JavaScript (although it does use a built-in SharePoint JavaScript function).
The trick I used was to open the form in a dialog. That way, when you click Cancel, the dialog is dismissed and you remain on the same page from which you opened the dialog.
Here’s some example html.
<a href="javascript:OpenPopUpPage(‘uploadfile.aspx?ProjectID={@PMO_x0020_Project_x0020_ID}’, RefreshPage);">
In this case, uploadfile.aspx is located in the pages library and is a custom page with an InfoPath form web part on it. The custom page also has a URL filter on it that is connected to the form. The parameter, ProjectID, is a URL parameter that is passed to the form through a web part connection.
Here is an image that has the above hyperlink (Upload File) anchored to it.
This opens the page below in a dialog. Notice how the Project ID is defaulted on the form using a URL parameter that is sent to the form web part using a web part connection.
When Cancel is clicked, the dialog is dismissed and we’re right back where we started.
For the "Thank you" page, I’d recommend creating another view in InfoPath and simply switching views after the submit with your "thank you" text and provide an OK button to close the form.
Is it possible to route to another parent page upon the dialogs closure? Essentially replacing refreshpage with a new URL to go to.
It should be.