PDA

View Full Version : Script Does not allow page to load in IE7



highalpine
10-09-2008, 03:07 PM
here is the java that I'm using..

Quote Array:


<SCRIPT type="text/javascript">
var quotations = new Array()
quotations[0]= "I have not failed. I've just found 10,000 ways that don't work.<br /><b>Thomas Alva Edison</b>"
quotations[1]= "The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier.<br /><b>Bill Gates</b>"
quotations[2]= "Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.<br /><b>Andy Rooney</b>"
quotations[3]= "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.<br /><b>Albert Einstein</b>"
quotations[4]= "Whether you think that you can, or that you can't, you are usually right.<br /><b>Henry Ford</b>"
quotations[5]= "To have a quiet mind is to possess one's mind wholly; to have a calm spirit is to possess one's self<br /><b>Hamilton Mabie</b>"
function display()
{
a=Math.floor(Math.random()*quotations.length)
document.getElementById('quotation').innerHTML=quotations[a]
setTimeout("display()",5000)
}
</SCRIPT>

Display Code:


<SCRIPT type="text/javascript">display()</SCRIPT>


error that IE7 give me:


Internet Explorer cannot open the Internet site http://designdt.co.cc/book

Operation aborted



IE7 then takes you to a page could not load screen..

Any help on fixing this would be great....

thanks.

jscheuer1
10-09-2008, 03:57 PM
There are some minor issues I have with the script. For one the variable a should be formally declared. But even without fixing that or other minor things, this worked fine here in IE 7 locally:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT type="text/javascript">
var quotations = new Array()
quotations[0]= "I have not failed. I've just found 10,000 ways that don't work.<br /><b>Thomas Alva Edison</b>"
quotations[1]= "The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier.<br /><b>Bill Gates</b>"
quotations[2]= "Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.<br /><b>Andy Rooney</b>"
quotations[3]= "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.<br /><b>Albert Einstein</b>"
quotations[4]= "Whether you think that you can, or that you can't, you are usually right.<br /><b>Henry Ford</b>"
quotations[5]= "To have a quiet mind is to possess one's mind wholly; to have a calm spirit is to possess one's self<br /><b>Hamilton Mabie</b>"
function display()
{
a=Math.floor(Math.random()*quotations.length)
document.getElementById('quotation').innerHTML=quotations[a]
setTimeout("display()",5000)
}
</SCRIPT>
</head>
<body>
<div id="quotation"></div>
<SCRIPT type="text/javascript">display()</SCRIPT>
</body>
</html>

On your page, try changing:


<div id="quotation">
<p>&quot;
<SCRIPT type="text/javascript">display()</SCRIPT>
&quot;</p>
</div>

to:


<div>&quot;<span id="quotation"></span>&quot;</div>
<SCRIPT type="text/javascript">display()</SCRIPT>

jscheuer1
10-09-2008, 04:33 PM
Here it is with all of those minor issues I saw worked out:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
display.quotations = new Array();
display.quotations[0] = ["I have not failed. I've just found 10,000 ways that don't work.", "Thomas Alva Edison"];
display.quotations[1] = ["The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier.", "Bill Gates"];
display.quotations[2] = ["Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.", "Andy Rooney"];
display.quotations[3] = ["Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.", "Albert Einstein"];
display.quotations[4] = ["Whether you think that you can, or that you can't, you are usually right.", "Henry Ford"];
display.quotations[5] = ["To have a quiet mind is to possess one's mind wholly; to have a calm spirit is to possess one's self", "Hamilton Mabie"];

function display(){
var a = Math.floor(Math.random() * display.quotations.length),
d = document.getElementById('quotation'),
b = document.createElement('b'),
br = document.createElement('br');
while (d.lastChild)
d.removeChild(d.lastChild);
d.appendChild(document.createTextNode('"' + display.quotations[a][0] + '"'));
b.appendChild(document.createTextNode(display.quotations[a][1]));
d.appendChild(br); d.appendChild(b);
if (!display.running)
display.running = setInterval(display, 5000);
};
</script>
</head>
<body>
<div id="quotation"></div>
<script type="text/javascript">display();</script>
</body>
</html>

clueful
10-10-2008, 12:48 AM
here is the java that I'm using..Actually it's JavaScript, Java is another language.



error that IE7 give me:


Internet Explorer cannot open the Internet site http://designdt.co.cc/book

Operation aborted
As I recall the usual cause of this error is when a script that creates elements or changes element contents, is itself nested inside an element, instead of immediately within the <head> or <body>.

Unfortunately you haven't shown enough code to be able to check this.

Also try validating your markup: http://validator.w3.org

jscheuer1
10-10-2008, 08:29 AM
error that IE7 give me:


Internet Explorer cannot open the Internet site http://designdt.co.cc/book

Operation aborted


Actually it's JavaScript, Java is another language.

As I recall the usual cause of this error is when a script that creates elements or changes element contents, is itself nested inside an element, instead of immediately within the <head> or <body>.

Unfortunately you haven't shown enough code to be able to check this.

Also try validating your markup: http://validator.w3.org

Actually, all the code we need to see is at the address given by the error message. And as you speculated, and as I pointed out, it is:


On your page, try changing:


<div id="quotation">
<p>&quot;
<SCRIPT type="text/javascript">display()</SCRIPT>
&quot;</p>
</div>

to:


<div>&quot;<span id="quotation"></span>&quot;</div>
<SCRIPT type="text/javascript">display()</SCRIPT>

Still, I prefer the code given in my second response in this thread (http://www.dynamicdrive.com/forums/showpost.php?p=165077&postcount=3), a vast improvement upon the original.