R
Robi
Ok, I'm sure everybody who works with javascript has seen this
or similar messages depending on their agent:
A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]
besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?
I am trying to list "all" the characters in tables (from #x0000-#xffff)
yeah, that's 65K characters...
the function is defined in the <head> section and goes:
<script type="text/javascript">
function createlist()
{
var hex="0123456789abcdef";
hex=hex.split("");
var fourth, third, second, first, spezial;
var oBody=document.getElementsByTagName("body").item(0);
var oTable, oTHead, oTBody, oTFoot, oCaption;
var oRow, oCell, oHell, oDiv;
for (first=0;first<=15;first++)
{
for (second=0;second<=15;second++)
{
oTable = document.createElement("table");
oTHead = document.createElement("thead");
oTBody = document.createElement("tbody");
oTFoot = document.createElement("tfoot");
oCaption = document.createElement("caption");
oTable.appendChild(oCaption);
oTable.appendChild(oTHead);
oTable.appendChild(oTBody);
oTable.appendChild(oTFoot);
oTable.border=1;
oRow=document.createElement("tr");
oTHead.appendChild(oRow);
oCell = document.createElement("th");
oCell.appendChild(document.createTextNode("Hex"));
oRow.appendChild(oCell);
oBody.appendChild(oTable);
for (oHell=0;oHell<16;oHell++){
oCell = document.createElement("th");
oCell.appendChild(document.createTextNode(hex[oHell]));
oRow.appendChild(oCell);
}
oTBody = document.createElement("tbody");
oTable.appendChild(oTBody);
for (third=0;third<=15;third++)
{
oRow=document.createElement("tr");
oTBody.appendChild(oRow);
oCell=document.createElement("td");
oCell.appendChild(document.createTextNode("&#x"+hex[first]+hex[second]+"n"+hex[third]+";"));
oRow.appendChild(oCell);
for (fourth=0;fourth<=15;fourth++)
{
oCell=document.createElement("td");
oCell.innerHTML="&#x"+hex[first]+hex[second]+hex[fourth]+hex[third]+";";
oRow.appendChild(oCell);
}
}
}
}
}
</script>
and then in the body I call
<script type="text/javascript">
createlist();
</script>
plain and simple, well, except for the load it creates iterating through 16^4
characters creating 16^2 tables and 16^4+16^2 cells and 16^3+16^2 rows
(rough calculations off the top of my head ;-)
Is there a way to diffuse the load and still getting all the tables created?
or similar messages depending on their agent:
A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]
besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?
I am trying to list "all" the characters in tables (from #x0000-#xffff)
yeah, that's 65K characters...
the function is defined in the <head> section and goes:
<script type="text/javascript">
function createlist()
{
var hex="0123456789abcdef";
hex=hex.split("");
var fourth, third, second, first, spezial;
var oBody=document.getElementsByTagName("body").item(0);
var oTable, oTHead, oTBody, oTFoot, oCaption;
var oRow, oCell, oHell, oDiv;
for (first=0;first<=15;first++)
{
for (second=0;second<=15;second++)
{
oTable = document.createElement("table");
oTHead = document.createElement("thead");
oTBody = document.createElement("tbody");
oTFoot = document.createElement("tfoot");
oCaption = document.createElement("caption");
oTable.appendChild(oCaption);
oTable.appendChild(oTHead);
oTable.appendChild(oTBody);
oTable.appendChild(oTFoot);
oTable.border=1;
oRow=document.createElement("tr");
oTHead.appendChild(oRow);
oCell = document.createElement("th");
oCell.appendChild(document.createTextNode("Hex"));
oRow.appendChild(oCell);
oBody.appendChild(oTable);
for (oHell=0;oHell<16;oHell++){
oCell = document.createElement("th");
oCell.appendChild(document.createTextNode(hex[oHell]));
oRow.appendChild(oCell);
}
oTBody = document.createElement("tbody");
oTable.appendChild(oTBody);
for (third=0;third<=15;third++)
{
oRow=document.createElement("tr");
oTBody.appendChild(oRow);
oCell=document.createElement("td");
oCell.appendChild(document.createTextNode("&#x"+hex[first]+hex[second]+"n"+hex[third]+";"));
oRow.appendChild(oCell);
for (fourth=0;fourth<=15;fourth++)
{
oCell=document.createElement("td");
oCell.innerHTML="&#x"+hex[first]+hex[second]+hex[fourth]+hex[third]+";";
oRow.appendChild(oCell);
}
}
}
}
}
</script>
and then in the body I call
<script type="text/javascript">
createlist();
</script>
plain and simple, well, except for the load it creates iterating through 16^4
characters creating 16^2 tables and 16^4+16^2 cells and 16^3+16^2 rows
(rough calculations off the top of my head ;-)
Is there a way to diffuse the load and still getting all the tables created?