搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

javascript settimer broken FF 73.0

  • 2 回覆
  • 1 有這個問題
  • 1 次檢視
  • 最近回覆由 jamescobban

more options

I have the following Javascript code which has been working for over 10 years and still works on Chrome, but does not work on FF 73.0 on Ubuntu Linux.

```

/************************************************************************

*  timer														        *
*																		*
*  This timer is started whenever the user presses a key in the input	*
*  field and pops if 0.9 second passes without a new keystroke			*
************************************************************************/

var timer = null;

/************************************************************************

*  function onKeyDownName												*
*																		*
*  This method is called when a key is pressed in the Name field.		*
*  A timer is set so that when the user stops typing the selection		*
*  list is repopulated.												*
*																		*
*  Input:																*
*		event	if passed, event.keyCode identifies the key pressed		*
*				in older releases of Internet Explorer use window.event	*
************************************************************************/

function onKeyDownName(event) {

   if (timer)

clearTimeout(timer);

   timer	= setTimeout(update, 900);

} // function onKeyDownName

/************************************************************************

*  function update														*
*																		*
*  This method is called when the user stops typing to repopulate		*
*  the selection list based upon the current contents of the Name		*
*  field.  It is also the onchange method for the following fields:	*
*  'birthmin', 'birthmax', 'incMarried', 'includeParents',				*
*  'includeSpouse', and 'Sex', and it is called by the onchange		*
*  method for the field 'treeName'.									*
************************************************************************/

function update() {

   var	form	= document.nameForm;
   if (form)
   {		// form present

var url = "/FamilyTree/getIndivNamesXml.php"; ... code to complete url by appending values of elements from form // invoke script to obtain list of names for selection list HTTP.getXML(url, // see O'Reilly Javascript gotNames, noNames);

// clear out the old selection list while we are waiting var select = form.individ; select.options.length = 0;

// put a dummy entry at the top of the selection, otherwise // selecting the first name does not call onchange var name = '[choose an individual]'; var option = new Option(name, -1, false, false); option.innerHTML = '[choose an individual]'; select.appendChild(option);

   }		// form present
   else
       alert("nominalIndex.js:update: cannot find form");

} // function update ```


When I put alerts into nameOnKeyDown and update I see that nameOnKeyDown is called but update is never called.

You can see the above code in action at https://www.jamescobban.net/FamilyTree/nominalIndex.php?name=allenby,%20a&treename=&lang=en

This code has worked for over 10 years, and still is working today on Chrome, but the timer never pops on Firefox 73.0 on Ubuntu Linux 19.10.

I have the following Javascript code which has been working for over 10 years and still works on Chrome, but does not work on FF 73.0 on Ubuntu Linux. ``` /************************************************************************ * timer * * * * This timer is started whenever the user presses a key in the input * * field and pops if 0.9 second passes without a new keystroke * ************************************************************************/ var timer = null; /************************************************************************ * function onKeyDownName * * * * This method is called when a key is pressed in the Name field. * * A timer is set so that when the user stops typing the selection * * list is repopulated. * * * * Input: * * event if passed, event.keyCode identifies the key pressed * * in older releases of Internet Explorer use window.event * ************************************************************************/ function onKeyDownName(event) { if (timer) clearTimeout(timer); timer = setTimeout(update, 900); } // function onKeyDownName /************************************************************************ * function update * * * * This method is called when the user stops typing to repopulate * * the selection list based upon the current contents of the Name * * field. It is also the onchange method for the following fields: * * 'birthmin', 'birthmax', 'incMarried', 'includeParents', * * 'includeSpouse', and 'Sex', and it is called by the onchange * * method for the field 'treeName'. * ************************************************************************/ function update() { var form = document.nameForm; if (form) { // form present var url = "/FamilyTree/getIndivNamesXml.php"; ... code to complete url by appending values of elements from form // invoke script to obtain list of names for selection list HTTP.getXML(url, // see O'Reilly Javascript gotNames, noNames); // clear out the old selection list while we are waiting var select = form.individ; select.options.length = 0; // put a dummy entry at the top of the selection, otherwise // selecting the first name does not call onchange var name = '[choose an individual]'; var option = new Option(name, -1, false, false); option.innerHTML = '[choose an individual]'; select.appendChild(option); } // form present else alert("nominalIndex.js:update: cannot find form"); } // function update ``` When I put alerts into nameOnKeyDown and update I see that nameOnKeyDown is called but update is never called. You can see the above code in action at https://www.jamescobban.net/FamilyTree/nominalIndex.php?name=allenby,%20a&treename=&lang=en This code has worked for over 10 years, and still is working today on Chrome, but the timer never pops on Firefox 73.0 on Ubuntu Linux 19.10.

由 jamescobban 於 修改

被選擇的解決方法

Hi jamescobban

This is a user support focused forum and because of this there aren't many folks who can answer developer questions like your question.

The best place is stack overflow: https://stackoverflow.com/questions/tagged/firefox

More details: https://support.mozilla.org/en-US/kb/where-go-developer-support

Cheers!

...Roland

從原來的回覆中察看解決方案 👍 0

所有回覆 (2)

more options

選擇的解決方法

Hi jamescobban

This is a user support focused forum and because of this there aren't many folks who can answer developer questions like your question.

The best place is stack overflow: https://stackoverflow.com/questions/tagged/firefox

More details: https://support.mozilla.org/en-US/kb/where-go-developer-support

Cheers!

...Roland

more options

Thank you for looking at my report.

This wasn't a developer question because I wasn't asking how to get the code working. It was a caution that I had observed a specific problem on a specific release of Firefox that was not observed on other browsers. However the problem has now gone away as mysteriously as it appeared with no changes to any of my code.