Skip to main content

Displaying MiniMessages

Advance preparation​

OpenSocial has a feature that displays messages to users like simple dialog. Use of the minimessage feature must be declared with Required Elements in Gadget XML in order to use this feature.

<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Hello, world!">
<Require feature="minimessage" />
...

Displaying MiniMessages with a Close button​

The following are display examples of MiniMessages with a button the user can click to close the window.

var msg = new gadgets.MiniMessage();
msg.createDismissibleMessage("The high score has been updated", function() {
// ...
});
  • Generate a Message object with new gadgets.MiniMessage().
  • Make the message an argument in createDismissibleMessage() and call it to display the message.
  • If a callback function is specified in the second argument, it will be called when the user clicks the Close button.

Displaying MiniMessages that are erased after a specified period of time​

The following are display examples of MiniMessages that are closed after a specified period of time.

var msg = new gadgets.MiniMesage();
msg.createTimerMessage("The high score has been updated", 5, funciton() {
// ...
});
  • Generate a Message object with new gadgets.MiniMessage().
  • Specify the number of seconds until the message is closed in createTimerMessage() and call it to display the message.
  • If a callback function is specified for the third argument, it will be called when the message closes.

Displaying static MiniMessages​

The following are display examples of MiniMessages that are closed by the program.

var msg = new gadgets.MiniMessage();
var m = msg.createStaticMessage("The high score has been updated");
m.onclick = function() {
msg.dismissMessage(m);
}
  • Generate a Message object with new gadgets.MiniMessage().
  • Specify the message in createStaticMessage() and call it to display the message.
  • When the return value DOM element onclick is used and the message is clicked, the dismissMessage() method is called and the message is erased.

Revision History​

  • 12/2010
    • Initial Release.