'javasscript function run every time when the page reload on Edge

I have many user control on the page. A button on the user controls generate the script to send email using mailto function. Another button on another user control for opening popup window to add a record then reload the parent page. It is work fine on IE ;I use window.dialogArgument. However on Edge I used window.opener.location.reload();. The mailto function run again after clicking another button. I know I can set the URL on location.href but many pages have this issue that will spend too much time to update the code. Would someone has simply way to solve it. Thanks in advance.

There is the code to generate the email and it run every time when the parent page is reload.

Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
     Dim script As String = "location.href = 'mailto:" & emailTo
     script = script & "&subject=Test Subject"  & "&body=" & msg & "';"
     page.ClientScript.RegisterStartupScript(page.GetType(), "mail", script, True)
End Sub

There is a code to close the popup and reload the page on Edge

window.opener.location.reload(); window.close(); 

I tried window.location.href = window.location.href; window.close(); but it doesn't reload the page.



Solution 1:[1]

I added the dummy button on the parent page and run the btn.click at then end of the script function. The script function doesn't run

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user819774