最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to add image in alert or in propmts.alert using JavaScript XUL - Stack Overflow

programmeradmin0浏览0评论

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/embedp/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 prompts.alert box using JavaScript in XUL?

https://developer.mozilla/en/XPCOM_Interface_Reference/nsIPromptService#prompt_example https://developer.mozilla/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/embedp/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 prompts.alert box using JavaScript in XUL?

Share Improve this question edited Mar 8, 2013 at 9:01 j0k 22.8k28 gold badges81 silver badges90 bronze badges asked Aug 26, 2011 at 10:29 linguinilinguini 1,9397 gold badges49 silver badges80 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

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/keymaster/gatekeeper/there.is.only.xul"
   xmlns:html="http://www.w3/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?

发布评论

评论列表(0)

  1. 暂无评论