在Firefox插件中修改alert/confirm等对话框的标题

https://developer.mozilla.org/en/nsIPromptService

如果使用 window.alert 或者 window.confirm 等对话框,其title是没有办法改变的。

为了能够在火狐插件中修改这种对话框的标题,可以使用如下代码替换:

function triggerAlert(title, message) {
	var nsIPS = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
	nsIPS.alert(null, title, message); 
}

function triggerConfirm(title, message) {
	var nsIPS = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
	return nsIPS.confirmCheck(null, title, message, "", {value : false});
}

更多资料,请参考:

https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPromptService

http://www.ibm.com/developerworks/cn/web/1108_chengfu_ffplugin/

https://developer.mozilla.org/en/Code_snippets/Dialogs_and_Prompts#Passing_arguments_and_displaying_a_dialog

https://developer.mozilla.org/En/XUL

https://www.ibm.com/developerworks/cn/web/wa-lo-firefox-ext/


你可能感兴趣的:(function,null,interface,Firefox插件)