Howto: Append wizardpage in javascript

To append wizardpages dynamically using Javascript, you need to call internal function of wizard after the appendChild.

Example

<wizard id="wizardID" onload="wizard_onload()">
  <script type="text/javascript"><![CDATA[
function wizard_onload() {
  var myWizard = document.getElementById('wizardID');
  if (myWizard) {
    var myWizardPage = document.createElement('wizardpage');
    myWizardPage.setAttribute('label', 'wizardpage js');
    myWizard.appendChild(myWizardPage);

    // refresh wizard internal variables
    // constructor, see http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/wizard.xml
    myWizard._initWizardButton("back");
    myWizard._initWizardButton("next");
    myWizard._initPages();
    myWizard.pageCount = myWizard.wizardPages.length;
    myWizard.advance();
  }
}
  ]]></script>

</wizard>

Source: developer.mozilla.org (yan.morin) and deleted by Enn without explication.