I made a webpage that finds factors of numbers (I know, how exciting [YAWN]). But if you enter a number too large the internet web page crashes and a message appears:
[QUOTE]
Stop running this script?
A script on this page is causing Internet Explorer to run slowly. If it continues, your computer might become unresponsive.
I would much rather my own personalised message to appear instead because that message may seem a bit ‘frightening’ to someone and might immediately clicked yes – do stop running the scripts
I tried using a ‘try and catch’ statement but couldn’t incorporate it.
My Code is as follows (although you may not even have to read any of it if you know a solution):
[CODE]function FindFactors(Input, Maximum){
Input2 = Input
while(Input2 <= Maximum){
try {
FactorsFound.push(“<b>The Factors of ” + Input2 + ” are:</b><p style = ‘margin: 0, 0, 25px, 0; position:relative; left:20px;’>”)
TotalFactorsFound = 0
for(i = 1; i <= Math.sqrt(Input2); i++){
Input3 = Input2/i
if(Input3 == Math.round(Input3)){
FactorsFound.push(Math.round(i) + ” * ” + Input3)
TotalFactorsFound += 2
}
}
TotalFactorsFound -= (Math.sqrt(Input2) == Math.round(Math.sqrt(Input2))) ? 1 : 0
if(TotalFactorsFound == 1){
FactorsFound.push(“The Number ” + Input2 + ” has ” + TotalFactorsFound + ” Factor”)
}else if(TotalFactorsFound == 2){
FactorsFound.push(“The Number ” + Input2 + ” has ” + TotalFactorsFound + ” Factors, Making it a <b><u>Prime Number</u></b>”)
}else{
FactorsFound.push(“The Number ” + Input2 + ” has ” + TotalFactorsFound + ” Factors”)
}
FactorsFound.push(“</p>”)
Input2++
}catch (err){
Error2()
}
}
DisplayFactors(FactorsFound, Input)
}
Is it even possible to do what I am trying to do. Also, I imagine other web browsers have a similar system to IE – they stopping running scripts when it becomes to much to handle, but I don’t have to worry about that for now.
Thanks