|
|
Line 1: |
Line 1: |
| == How to create a clickable link which launches the users's default application to compose a mail message ==
| | See [http://developer.mozilla.org/en/docs/XUL:Attribute:href XUL:Attribute:href] at [http://developer.mozilla.org MDC]. |
|
| |
|
| '''Add this XUL to your extension:'''
| | [[Category:Redirects]] |
| | |
| <text value="Send me email" style="color: blue; cursor: pointer" onclick="sendMeMail();"/>
| |
| | |
| | |
| '''And add this javascript:'''
| |
| | |
| function sendMeMail() {
| |
| // Taken from browser.js's MailIntegration class
| |
| var mailtoUrl = "mailto:foobar@yahoo.com?body=cats%20and%20dogs&subject=firefox%20passwordmaker%20extension";
| |
| var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
| |
| var uri = ioService.newURI(mailtoUrl, null, null);
| |
| // now pass this url to the operating system
| |
| // a generic method which can be used to pass arbitrary urls to the operating system.
| |
| // aURL --> a nsIURI which represents the url to launch
| |
| var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);
| |
| if (extProtocolSvc)
| |
| extProtocolSvc.loadUrl(uri);
| |
| }
| |
| | |
| ===References===
| |
| http://forums.mozillazine.org/viewtopic.php?t=225243
| |
| | |
| [[Category:Example code]] | |
Latest revision as of 20:58, 23 May 2007