How to add image in alert or in propmts.alert using JavaScript XUL
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService#prompt_example https://developer.mozilla.org/en/Code_snippets/Alerts_and_Notifications
Mozilla XUL offers various types of alert and notification box messages. But, still why can't we have an image in the alert message?
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
prompts.alert(null, contact, "No Email Address")
The above code to display an alert with custom title message. When we check the nsIPromptService
, it give various options but still there is no possibility of adding an image according to my knowledge.
When we check the popup in XUL, we can add an image
but the alert will display in the corner of the system because it's using the nsIAlertsService
and the display of this pop-up is platform independent.
Would it be possible to have an image in the alert box or in the promp开发者_开发问答ts.alert box using JavaScript in XUL?
Why don't you use a custom alert dialog as discussed HERE ?
XUL for the alert with image may be like:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<dialog id="alertprompt" title="Alert"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
buttons="accept"
buttonlabelaccept="Ok"
height="160"
width="260"
ondialogaccept="return alert_prompt.doOK();">
<script type="application/javascript" src="chrome://hello/content/alert_prompt.js"/>
<label id="title" value="Title may go here!" align="center" class="header"/>
<html:table>
<html:tr>
<html:td>
<html:img src="Firefoxlogo.png" width="30" height="30"/>
</html:td>
<html:td>
<label id="result" value="This place will display your message." align="center"/>
</html:td>
</html:tr>
</html:table>
</dialog>
It will look something like:
Does it meet your requirement?
精彩评论