prem_amrit
Sep 13th, 2007, 10:28 PM
I'm trying to get this to work, but well, I'm not that good, or else I'm too tired to get the problem.
When I use this code it is suppose to be linebreaks, but they don't work.
Also, is there any way to parse HTML-syntax inside variables?
Actually I would like to have the first line bold and the other to lines stays unchanged.
Anyhow, I tried this for a few hours now and well, my brain won't go further right now.
var beforeMsg = "<strong>";
var afterMsg = "</strong";
var msgRotateSpeed = 5000; // Rotate delay in milliseconds
var textStr = new Array();
textStr[0] = "First bolded line"+
"\nSecond line"+
"\nThird line";
textStr[1] = "Second text";
textStr[2] = "Third text";
textStr[3] = "Fourth text";
if (document.layers) {
document.write('<ilayer id="NS4message" height=25 width=100%><layer id="NS4message2" height=25 width=100%></layer></ilayer>')
temp = 'document.NS4message.document.NS4message2.document.write(beforeMsg + textStr[t++] + afterMsg);'+
'document.NS4message.document.NS4message2.document.close()';
}
else if (document.getElementById) {
document.write(beforeMsg + '<div id="message"> </div>' + afterMsg);
temp = 'document.getElementById("message").firstChild.nodeValue = textStr[t++];';
}
else if (document.all) {
document.write(beforeMsg + '<div id="message"> </div>' + afterMsg);
temp = 'message.innerHTML = textStr[t++];';
}
var t = 0;
function msgRotate() {
eval(temp);
if (t == textStr.length) t = 0;
setTimeout("msgRotate()", msgRotateSpeed);
}
window.onload = msgRotate;
When I use this code it is suppose to be linebreaks, but they don't work.
Also, is there any way to parse HTML-syntax inside variables?
Actually I would like to have the first line bold and the other to lines stays unchanged.
Anyhow, I tried this for a few hours now and well, my brain won't go further right now.
var beforeMsg = "<strong>";
var afterMsg = "</strong";
var msgRotateSpeed = 5000; // Rotate delay in milliseconds
var textStr = new Array();
textStr[0] = "First bolded line"+
"\nSecond line"+
"\nThird line";
textStr[1] = "Second text";
textStr[2] = "Third text";
textStr[3] = "Fourth text";
if (document.layers) {
document.write('<ilayer id="NS4message" height=25 width=100%><layer id="NS4message2" height=25 width=100%></layer></ilayer>')
temp = 'document.NS4message.document.NS4message2.document.write(beforeMsg + textStr[t++] + afterMsg);'+
'document.NS4message.document.NS4message2.document.close()';
}
else if (document.getElementById) {
document.write(beforeMsg + '<div id="message"> </div>' + afterMsg);
temp = 'document.getElementById("message").firstChild.nodeValue = textStr[t++];';
}
else if (document.all) {
document.write(beforeMsg + '<div id="message"> </div>' + afterMsg);
temp = 'message.innerHTML = textStr[t++];';
}
var t = 0;
function msgRotate() {
eval(temp);
if (t == textStr.length) t = 0;
setTimeout("msgRotate()", msgRotateSpeed);
}
window.onload = msgRotate;