avalon
05-06-2003, 06:53 PM
I must be the 9999999'th person to bother u guys with a coding problem but here goes...
This code checks a textarea for strings like "[B]", "[U]", depending on the type given. Now everytime I run this, my browser crashes so I'm looking for an endless loop but I can't find any, can u guys find any other cause ? Or can an array out of bounds crash your browser too ? (altho I guess thats not the case here...).
function checkOpenTags(type)
{
type = "[" + type + "]";
message = document.form.message.value;
for(i=0;i<=message.length;i++)
{
if(message.substr(i,i+type.length)==type)
{return "false";}
else{return "true";}
}
}
function closeAll()
{
none = true;
message = document.form.message.value;
var type = new Array(9);
var waarde = new Array(9);
waarde[0] = "B";
waarde[1] = "I";
waarde[2] = "U";
waarde[3] = "FONT";
waarde[4] = "SIZE";
waarde[5] = "COLOR";
waarde[6] = "PHP";
waarde[7] = "CODE";
waarde[8] = "QUOTE";
for(i=0;i<8;i++)
{
type[i] = checkOpenTags(waarde[i]);
}
for(i=0;i<8;i++)
{
if(type[i] == "true")
{document.form.message.value = message + "[/" + waarde[i] + "]"; none=false;}
}
if(none == true)
{document.form.status.value = "<< No open tags detected. >>";}
}
PS: Some of you might have noticed that this is for a forum, and yes I'm developing one on my own, one that looks a lot like the vBulletin Forums... just different layout and some different functions. ( http://board.avaweb.be )
thx in advance
greetz ava
This code checks a textarea for strings like "[B]", "[U]", depending on the type given. Now everytime I run this, my browser crashes so I'm looking for an endless loop but I can't find any, can u guys find any other cause ? Or can an array out of bounds crash your browser too ? (altho I guess thats not the case here...).
function checkOpenTags(type)
{
type = "[" + type + "]";
message = document.form.message.value;
for(i=0;i<=message.length;i++)
{
if(message.substr(i,i+type.length)==type)
{return "false";}
else{return "true";}
}
}
function closeAll()
{
none = true;
message = document.form.message.value;
var type = new Array(9);
var waarde = new Array(9);
waarde[0] = "B";
waarde[1] = "I";
waarde[2] = "U";
waarde[3] = "FONT";
waarde[4] = "SIZE";
waarde[5] = "COLOR";
waarde[6] = "PHP";
waarde[7] = "CODE";
waarde[8] = "QUOTE";
for(i=0;i<8;i++)
{
type[i] = checkOpenTags(waarde[i]);
}
for(i=0;i<8;i++)
{
if(type[i] == "true")
{document.form.message.value = message + "[/" + waarde[i] + "]"; none=false;}
}
if(none == true)
{document.form.status.value = "<< No open tags detected. >>";}
}
PS: Some of you might have noticed that this is for a forum, and yes I'm developing one on my own, one that looks a lot like the vBulletin Forums... just different layout and some different functions. ( http://board.avaweb.be )
thx in advance
greetz ava