I think I'm down to my last error code, but I can't seem to find the problem. This code works find in IE but I get an javascript error in NS
JavaScript Error:
file:/D:/My%20Documents/Bottomlee.com/Stationery%201.htm,
line 95:
can't convert x to an integer.
This is line 95:
else
{ // code for NS
butterfly.left = x; // this is line 95
butterfly.top = y;
A few lines before 95 I use this code to make sure that var x & y were integers
x = Math.round(R*Math.cos(A)+cx);
y = Math.round(R*Math.sin(A)+cy);
So I don't know why I'm getting this error. Can someone help me
Photo Joe
The complete code for the page is below:
<HTML>
<HEAD>
<STYLE TYPE="text/css">
body {
font-family: "Comic Sans MS";
font-size: 16pt;
margin-left: 420;
background-color: #000000;
color: #F0F0FF;
}
</STYLE>
<title></title>
<bgsound src="Midi/4marys.mid" balance="0" volume="0" loop="infinite">
<STYLE TYPE="text/css">
<!--
#butterfly {position:absolute; top: 0px; left:0px;}
-->
</STYLE>
<!-- An optional background image can be used but it will not scroll -->
</HEAD>
<BODY OnLoad= "window_OnLoad()"
<!-- This is the object in orbit. You should include the height and width background="images/Other/AK306.jpg" -->
<SPAN id=butterfly>
<img name = "pic" border="0" src="images/Other/monarch3_flap_md_clr.gif" width="70" height="80" style="position: absolute; top: 0; left: 0;">
</SPAN>
<SCRIPT language="JavaScript">
// Edgar V. Poirier
// [email protected]
// Dim w, wW, wH, myTimer, A, R, cx, cy, x, y
var w=document.body;
var myTimer = null;
var w;
var wW;
var wH;
var pic = document.images["pic"];
var A = 0, R = 0, cx = 0, cy = 0, x = 0, y = 0
if(document.layers)
{
var butterfly = document.layers["butterfly"]; // set var for NS object for butterfly gif
}
// Initialize
function window_OnLoad()
{
// Get Window dimensions
wW = screen.width;
wH = screen.height;
// Set the Radius;
R = wH/5;
A = 0; // Starting angle. Angles are in Radians. 1 degree = 3.14150/180 radians
// Set the center of the circle to 1/3 quadrant of the window
// Note the offset due to the fact that the object is
// positioned using its TOP and LEFT properties.
if (!document.layers) // test for browser type true =IE false = NS
{ // code if IE
cx = wW/3 - pic.width;
cy = wH/3 - pic.height;
}
else
{ // code for NS
var butterfly = document.layers["butterfly"]; // set var for NS object for butterfly gif
cx = wW/3 - butterfly.width;
cy = wH/3 - butterfly.height;
}
orbit();
}
// Move the object in a circle starting at an angle of 0, then increasing the angle.
function orbit()
{
clearTimeout(myTimer);
// Increase the angle
A=A+.01;
// Calculate the new coordinates
x = Math.round(R*Math.cos(A)+cx);
y = Math.round(R*Math.sin(A)+cy);
// Position the object.
if (!document.layers) // test for browser type true =IE false = NS
{ // code if IE
pic.style.left=x;
pic.style.top=y;
}
else
{ // code for NS
butterfly.left = x; // this is line 95
butterfly.top = y;
}
// Repeat for next angle change.
myTimer=setTimeout("orbit()",20);
}
</SCRIPT>
<p></p>
</BODY>
</HTML>
JavaScript Error:
file:/D:/My%20Documents/Bottomlee.com/Stationery%201.htm,
line 95:
can't convert x to an integer.
This is line 95:
else
{ // code for NS
butterfly.left = x; // this is line 95
butterfly.top = y;
A few lines before 95 I use this code to make sure that var x & y were integers
x = Math.round(R*Math.cos(A)+cx);
y = Math.round(R*Math.sin(A)+cy);
So I don't know why I'm getting this error. Can someone help me
Photo Joe
The complete code for the page is below:
<HTML>
<HEAD>
<STYLE TYPE="text/css">
body {
font-family: "Comic Sans MS";
font-size: 16pt;
margin-left: 420;
background-color: #000000;
color: #F0F0FF;
}
</STYLE>
<title></title>
<bgsound src="Midi/4marys.mid" balance="0" volume="0" loop="infinite">
<STYLE TYPE="text/css">
<!--
#butterfly {position:absolute; top: 0px; left:0px;}
-->
</STYLE>
<!-- An optional background image can be used but it will not scroll -->
</HEAD>
<BODY OnLoad= "window_OnLoad()"
<!-- This is the object in orbit. You should include the height and width background="images/Other/AK306.jpg" -->
<SPAN id=butterfly>
<img name = "pic" border="0" src="images/Other/monarch3_flap_md_clr.gif" width="70" height="80" style="position: absolute; top: 0; left: 0;">
</SPAN>
<SCRIPT language="JavaScript">
// Edgar V. Poirier
// [email protected]
// Dim w, wW, wH, myTimer, A, R, cx, cy, x, y
var w=document.body;
var myTimer = null;
var w;
var wW;
var wH;
var pic = document.images["pic"];
var A = 0, R = 0, cx = 0, cy = 0, x = 0, y = 0
if(document.layers)
{
var butterfly = document.layers["butterfly"]; // set var for NS object for butterfly gif
}
// Initialize
function window_OnLoad()
{
// Get Window dimensions
wW = screen.width;
wH = screen.height;
// Set the Radius;
R = wH/5;
A = 0; // Starting angle. Angles are in Radians. 1 degree = 3.14150/180 radians
// Set the center of the circle to 1/3 quadrant of the window
// Note the offset due to the fact that the object is
// positioned using its TOP and LEFT properties.
if (!document.layers) // test for browser type true =IE false = NS
{ // code if IE
cx = wW/3 - pic.width;
cy = wH/3 - pic.height;
}
else
{ // code for NS
var butterfly = document.layers["butterfly"]; // set var for NS object for butterfly gif
cx = wW/3 - butterfly.width;
cy = wH/3 - butterfly.height;
}
orbit();
}
// Move the object in a circle starting at an angle of 0, then increasing the angle.
function orbit()
{
clearTimeout(myTimer);
// Increase the angle
A=A+.01;
// Calculate the new coordinates
x = Math.round(R*Math.cos(A)+cx);
y = Math.round(R*Math.sin(A)+cy);
// Position the object.
if (!document.layers) // test for browser type true =IE false = NS
{ // code if IE
pic.style.left=x;
pic.style.top=y;
}
else
{ // code for NS
butterfly.left = x; // this is line 95
butterfly.top = y;
}
// Repeat for next angle change.
myTimer=setTimeout("orbit()",20);
}
</SCRIPT>
<p></p>
</BODY>
</HTML>
Comment