我刚开始玩Mozilla Jetpack,到目前为止我很喜欢它。我写了一个小代码,在状态栏中显示一个图标,当点击它时,会弹出一个通知:
var myTitle = 'Hello World!';
var line1 = 'I am the very model of a modern Major-General,';
var line2 = 'I\'ve information vegetable, animal, and mineral,';
var line3 = 'I know the kings of England, and I quote the fights historical,';
var line4 = 'From Marathon to Waterloo, in order categorical.';
var myBody = line1 + ' ' + line2 + ' ' + line3 + ' ' + line4;
var myIcon = 'http://www.stackoverflow.com/favicon.ico';
jetpack.statusBar.append({
html: '<img src="' + myIcon + '">',
width: 16,
onReady: function(doc) {
$(doc).find("img").click(function() {
jetpack.notifications.show({title: myTitle, body: myBody, icon: myIcon});
});
}
});
由于此示例中的文本很长,因此通知如下所示:
Jetpack 通知 http://img33.imageshack.us/img33/7113/jetpack.png
我想在显示通知的文本时将它们拆分为四个不同的行,以便通知框更高更窄。我该怎么做呢?
编辑 1(感谢Rudd Zwolinski):
我试过了,但这无济于事:
var myBody = line1 + '\n' + line2 + '\n' + line3 + '\n' + line4;
编辑 2(感谢Ólafur Waage):
这也无济于事:
var myBody = line1 + '<br />' + line2 + '<br />' + line3 + '<br />' + line4;
编辑 3(感谢马特):
即使这样也无济于事:
var myBody = line1 + "\n" + line2 + "\n" + line3 + "\n" + line4;