Answers.Body: <p>This happens when the built-in profile for user registration ("Name and Address" is the out-of-the-box title) is used on the contribution page. Swap it for another profile, and the pop-up does not appear. Replicated this on the Joomla CiviCRM demo site.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-13T21:39:59.687Z
Answers.Text: I'm getting this error using a different profile
Answers.UserDisplayName: Yossi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-22T17:37:57.277Z
Answers.Text: Would be good to narrow it down to the particular field in that profile that is causing it.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T17:50:03.060Z
Answers.Text: Thanks for prompting the clarification, Coleman. It's not any one of the fields - I used all the same ones in a new profile that's not the built-in one for user registration, and it works perfectly.
Answers.UserDisplayName: MtnPavlas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T18:27:29.717Z
Answers.Text: that's... weird.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-20T00:18:07.767Z
Answers.LastActivityDate: 2015-10-20T00:18:07.767Z
Answers.UserDisplayName: MtnPavlas
Answers.Body: <p>CiviCRM uses jQuery to watch form inputs and give a warning only if there are unsaved changes. You'll find the code for it in <a href="https://github.com/civicrm/civicrm-core/blob/4.6.9/js/Common.js#L897" rel="nofollow">Common.js</a>. When I try out a sample contribution page on the demo server it looks to be working correctly; if I open a <a href="http://d46.demo.civicrm.org/civicrm/contribute/transact?reset=1&amp;id=1" rel="nofollow">contribution page</a>, enter nothing and close the tab, I get no warning. But if I enter an amount and then try to leave it pops up the onbeforeunload message.</p>
  
  <p>If you're up for it, debugging the <code>CRM.utils.initialValueChanged</code> function to find out <em>why</em> civi thinks the form has been changed when it hasn't would be helpful feedback for us improving the software.</p>
  
  <p>Or you could just add a little javascript to your FB login button. If the existing markup looks like <code>&lt;button type="submit"&gt;</code> then you could add to it so it looks like <code>&lt;button type="submit" onclick="window.onbeforeunload = null;"&gt;</code></p>
  
  <p>But seriously, the debugging feedback would be helpful.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-19T16:06:43.723Z
Answers.Text: Thank you, Coleman, for the info. I'm not much of a developer but will look into why Civi thinks something has been changed on the form and post here for others (and for the Civi team).
Answers.UserDisplayName: MtnPavlas
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-22T14:04:59.377Z
Answers.Text: Just guessing -- is it possible browser auto-fill inserts something into the form?
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-09T13:56:04.470Z
Answers.Text: Thanks coleman! this one's been on my annoyance list for a while as well. Delighted that we can blame FB.
Answers.UserDisplayName: Alan Dixon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-17T02:35:57.827Z
Answers.LastActivityDate: 2015-10-17T02:35:57.827Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>In case it's of use to others: I wanted to make the recurring donation checkbox ("I want to contribute this amount every month") true (checked) by default on a particular donation form. I used the following custom javascript to do it. </p>
  
  <p>After setting the value to "checked" in javascript, the <code>.data('crm-initial-value', true)</code> code was necessary to prevent CiviCRM from complaining about unsaved changes when navigating to a different page.</p>
  
  <pre><code>&lt;script&gt; 
  CRM.$(function($) {
  // make recurring contribution checkbox true by default
  var r = $('#is_recur');
  if (!r.length) { return; }
  r.attr('checked', 'checked');
  r.prop('defaultChecked', true);
  r.prop('checked', true);
  // necessary to tell Civi the default value has changed
  r.data('crm-initial-value', true);
  &lt;/script&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-29T22:25:14.097Z
Answers.LastActivityDate: 2019-01-29T22:25:14.097Z
Answers.UserDisplayName: Martin_W
Body: <p>Where could I suppress the "are you sure you want to leave this page" popup when leaving a contribution page (e.g. donation) without actually proceeding with the contribution.
  I realize it may be there to prevent leaving the page accidentally mid-way through filling out the form but I actually think it's more annoying than helpful in the fraction of accidental cases.
  Also, I have a Facebook login on the page, which, when utilized, forces the page to reload and thus invokes the 'leave this page' popup. This is confusing to the user who wouldn't know they need to hit the "leave this page" button in order to get logged in (not to mention they'll actually stay on the page, hence the confusion).</p>
  
  <p>This is on Joomla (3.4.4 w/ CiviCRM 4.6.9)</p>
  
  <p>I'm assuming there's an <code>onbeforeunload</code> function - one appears in /administrator/components/com_civicrm/civicrm/js/Common.js</p>
  
  <p>The warning appears even when the user has not made any entries on the form. Shouldn't the warning only pop up when they do?</p>
  
  <p>Thank you for any pointers.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-16T22:40:31.037Z
Comments.Text: OK, so commenting out the 'onbeforeunload' function in the file I mentioned above definitely removes the popup but the way I should have really asked the question is how could we invoke the function only when something is entered/selected in the form on the page. Because in that case it's useful.
Comments.UserDisplayName: MtnPavlas
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-18T08:56:21.680Z
Comments.Text: I'd observed this behaviour once or twice lately on 4.6 sites I think, will take a moment to look into it if I see it again. It is kinda bothersome but since would have been happening when submitting or reloading, had just been hitting ESC or whatever makes it go away ASAP :D
Comments.UserDisplayName: Chris Burgess
Tags: <civicontribute>
Title: How do I suppress the "are you sure you want to leave this page" popup from contribution page
ThreadText: # How do I suppress the "are you sure you want to leave this page" popup from contribution page
  
  (Asked by: username_0 on 2015-10-16)
  
  Where could I suppress the "are you sure you want to leave this page" popup when leaving a contribution page (e.g. donation) without actually proceeding with the contribution.
  I realize it may be there to prevent leaving the page accidentally mid-way through filling out the form but I actually think it's more annoying than helpful in the fraction of accidental cases.
  Also, I have a Facebook login on the page, which, when utilized, forces the page to reload and thus invokes the 'leave this page' popup. This is confusing to the user who wouldn't know they need to hit the "leave this page" button in order to get logged in (not to mention they'll actually stay on the page, hence the confusion).
  
  This is on Joomla (3.4.4 w/ CiviCRM 4.6.9)
  
  I'm assuming there's an `onbeforeunload` function - one appears in /administrator/components/com\_civicrm/civicrm/js/Common.js
  
  The warning appears even when the user has not made any entries on the form. Shouldn't the warning only pop up when they do?
  
  Thank you for any pointers.
  
  **Tags:** civicontribute
  
  > **Comments:**
  > **username_0**: OK, so commenting out the 'onbeforeunload' function in the file I mentioned above definitely removes the popup but the way I should have really asked the question is how could we invoke the function only when something is entered/selected in the form on the page. Because in that case it's useful.  
  > **username_1**: I'd observed this behaviour once or twice lately on 4.6 sites I think, will take a moment to look into it if I see it again. It is kinda bothersome but since would have been happening when submitting or reloading, had just been hitting ESC or whatever makes it go away ASAP :D  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-10-20. Score: 1 | Accepted answer
  
  This happens when the built-in profile for user registration ("Name and Address" is the out-of-the-box title) is used on the contribution page. Swap it for another profile, and the pop-up does not appear. Replicated this on the Joomla CiviCRM demo site.
  
  > **Comments:**
  > **username_3**: Would be good to narrow it down to the particular field in that profile that is causing it.  
  > **username_0**: Thanks for prompting the clarification, username_3. It's not any one of the fields - I used all the same ones in a new profile that's not the built-in one for user registration, and it works perfectly.  
  > **username_3**: that's... weird.  
  > **username_2**: I'm getting this error using a different profile  
  
  ---
  
  ### Answer by username_3 on 2015-10-17. Score: 3
  
  CiviCRM uses jQuery to watch form inputs and give a warning only if there are unsaved changes. You'll find the code for it in [Common.js](https://github.com/civicrm/civicrm-core/blob/4.6.9/js/Common.js#L897). When I try out a sample contribution page on the demo server it looks to be working correctly; if I open a [contribution page](http://d46.demo.civicrm.org/civicrm/contribute/transact?reset=1&id=1), enter nothing and close the tab, I get no warning. But if I enter an amount and then try to leave it pops up the onbeforeunload message.
  
  If you're up for it, debugging the `CRM.utils.initialValueChanged` function to find out *why* civi thinks the form has been changed when it hasn't would be helpful feedback for us improving the software.
  
  Or you could just add a little javascript to your FB login button. If the existing markup looks like  then you could add to it so it looks like
  
  But seriously, the debugging feedback would be helpful.
  
  > **Comments:**
  > **username_0**: Thank you, username_3, for the info. I'm not much of a developer but will look into why Civi thinks something has been changed on the form and post here for others (and for the Civi team).  
  > **username_4**: Just guessing -- is it possible browser auto-fill inserts something into the form?  
  > **username_5**: Thanks coleman! this one's been on my annoyance list for a while as well. Delighted that we can blame FB.  
  
  ---
  
  ### Answer by username_6 on 2019-01-29. Score: 1
  
  In case it's of use to others: I wanted to make the recurring donation checkbox ("I want to contribute this amount every month") true (checked) by default on a particular donation form. I used the following custom javascript to do it. 
  After setting the value to "checked" in javascript, the .data('crm-initial-value', true) code was necessary to prevent CiviCRM from complaining about unsaved changes when navigating to a different page.
  
  
  ---
  
  