سؤال

I am creating a 10-question quiz based on JS prompts for a website the real developer is busy programming. That was easy enough to do, but the prompt box is not exactly aesthetically pleasing. Is there a way to incorporate a background image for the prompt box?

Thanks

هل كانت مفيدة؟

المحلول

IE:
IE

Chrome:
Chrome

Firefox:
Firefox

Not only is it ugly, it is also not even close to consistent. Don't use prompt.

Use a real <form> instead.

If you're a more advanced developer, you can try making your own custom prompt. My own toolbox has a function called Dialog in which I can define text fields, drop-downs, and much much more. Here's a simple example of a prompt-like dialog:
Pok&eacute;Farm Q

However, as I said, this is relatively advanced. The function Dialog(...) {...} code in my source files is filled with features but over 200 lines long, and the dialog shown above is created with the code...

Dialog("Hello!","Please answer the question:",
    {type:"input",value:"test",flex:3},
    // flex:3 results in it being three times bigger than the button
    {text:"Submit",onclick:function(inputs) {alert("You said "+inputs[0].value);}},
    {cancelable:true}
);

نصائح أخرى

For the default prompt box no you cannot. Although there are many libraries that offers functionality that is the same of the prompt box: jQuery UI for example: http://jqueryui.com/dialog/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top