Sometimes when we want to close a CRM form via javascript, we get the following error:

The webpage you are viewing is trying to close the window. Do you want to close this window?

Our customer didn’t liked this windows because it’s again one additional click to close the form. We have solved this by adding script to the form.

the page is trying to close the webpage

Browsers do this for security reasons. The rule is “only windows opened by javascript can close them by javascript.” In any other case, this pop-up window is displayed.

Add the following line of code to the beginning of your CRM form. And the pop-up won’t show up anymore:

window.top.open('', '_self', '');

Hope this could help.

Leave a Reply

Your email address will not be published. Required fields are marked *