Home > Net >  Creating a custom prompt with js
Creating a custom prompt with js

Time:10-01

I'm trying to create a custom version of the prompt() function in js, that can be styled according to client specs.

However, I am not sure how to get a custom function to pause scripts until a 'yes' or 'no' is selected, and therefore how to get that function to eval to either true or false the same way a simple prompt() would.

Can anyone point me in the right direction to research?

CodePudding user response:

Yeah prompt() can't be styled, it is an in-built browser feature and has no way of pausing until clicked.

As others have said, and also what I would do, is make a modal that you can style to your desire. Then, "promisify" it (in that, create a promise and once you select something, resolve the promise), and this will basically wait until 'yes' or 'no' is clicked.

  • Related