我刚刚开始玩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 Notification 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(感谢Matt):
即使这没有帮助:
var myBody = line1 + "\n" + line2 + "\n" + line3 + "\n" + line4;
如果将其添加到行中,“\ n”是否可以工作? – scunliffe 2009-05-22 15:41:40
@scunliffe,不,添加'\ n'没有帮助。 – eleven81 2009-05-22 15:45:28
他说“\ n”,而不是'\ n'。有一个微妙的区别。 – Matt 2009-05-22 16:34:49