私はそれを自分で得ることができました。私は約束がコードの終わりに達したときに何とか終了すると仮定していましたが、これは真実ではありません。したがって、ボタンのonclickを解決する唯一の可能性を持ってonclickを設定すると、ボタンが押されるのを待ちます。以下のコードサンプルを参照してください。
var modalPopup() = function() {
//Display the popup
document.getElementById("GeneralModalBackground").style.display = "flex";
return new Promise(function(resolve, reject) {
document.getElementById("GeneralSubmitButton").onclick = function() {
//when clicked, resolve the promise with the inputted value
let returnVal = document.getElementById("GeneralTextField").value;
resolve(returnVal);
}
});
}
modalPopup().then(function(textNeeded) {
//do stuff I need to do
});
コードサンプルが役に立ちます。また、質問を複数の段落に分割し、より具体的にしてみてください。 – nbkhope