...

View Full Version : Object expected error, but why?



greasonwolfe
09-21-2005, 07:18 PM
Okay, here is the code. . . I don't understand why it is giving me an Object Expected error at the body onload statement. Am I just being braindead and missing something obvious or has something changed yet again and left me in its wake? Anyways, if one of you would be so kind as to explain why I am getting this error, I would appreciate it much.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

<html lang=en-us>

<head>

<title>
Some Title Here
</title>

<style type="text/css">
<!--

.click {
cursor: pointer;
cursor: hand;
}

.imgfader {
position: absolute;
top: 7;
left: 100;
height: 425;
width: 820;
visibility: visible;
filter: alpha(opacity=10);
-moz-opacity: 10;
}

-->
</style>

<script type="text/javascript" carset="ISO-8859-1">
<!--
var allimgs=new Array("firstpicshere.jpg" . . . "lastpichere.jpg")
var imgload=new Array()

for (pl=0;pl<allimgs.length;pl++)
{
imgload[pl]=new Image()
imgload[pl].src=allimgs[pl]
}

var whichfade=new Array("illypic1","illypic2","illypic3")

function initialview()
{
document.getElementById(whichfade[1]).style.filter= "alpha(opacity=100)"
document.getElementById(whichfade[1]).style.-moz-opacity= "0"
document.getElementById(whichfade[2]).style.filter= "alpha(opacity=100)"
document.getElementById(whichfade[2]).style.-moz-opacity= "0"
}

-->
</script>

</head>

<body background="newdesertbg2.jpg" topmargin="0" leftmargin="0" bgproperties="fixed" onLoad="initialview()">
.
.
.
</html>

a_leon
09-21-2005, 09:17 PM
I may be mistaken, but I believe that rather than -moz-opacity, when calling it with JS rather than CSS, it is MozOpacity.

martin_narg
09-21-2005, 10:08 PM
You need to check whch style attributed is supported by the user's browser otherwise it will always error out in every browser.

This should work for you:

function initialview() {
for(var i=0; imgload[i]; i++) {
if(imgload[i].style.MozOpacity) {
imgload[i].style.MozOpacity = 0;
} else {
imgload[i].style.filters.alpha.opacity = 0;
}
}
}Hope this helps.

m_n

felgall
09-21-2005, 11:19 PM
That code will still give an error in browsers that don't support either opacity method such as Opera.

greasonwolfe
09-22-2005, 09:19 PM
I realized that I may not have posted enough of the coding to clearly identify my problem. With that in mind, I trimmed things back a bit and am just working with the Opacity feature as it applies to IE at this point. When I define the class, everything does just what it is supposed to. However, later, when I go to turn the opacity down on two of the three objects, it just doesnt seem to work at all. Here is the full coding up to the point that it should turn the opacity down . . .



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">

<html lang=en-us>

<head>

<title>
Mistress of the Maji : The Desert Queen of Snakes : Illyana Nightshade
</title>

<style type="text/css">
<!--

.imgfader {
position: absolute;
top: 7;
left: 100;
height: 425;
width: 820;
visibility: visible;
filter: alpha(opacity=100);
}

-->
</style>


This part works just fine when it is applied to the div elements later on.



<script type="text/javascript" charset="ISO-8859-1">
<!--
var allimgs=new Array("desertbg2.jpg","illyanaone.jpg","illyanatwo.jpg","illyanatre.jpg","temple.gif","momglyph.gif","momnonglyph.gif","roeglyph.gif","roenonglyph.gif","totmglyph.gif","totmnonglyph.gif")
var imgload=new Array()

for (pl=0;pl<allimgs.length;pl++)
{
imgload[pl]=new Image()
imgload[pl].src=allimgs[pl]
}

-->
</script>


As far as I can tell, this part is also working just fine though I haven't loaded it onto my server yet, so will have to double check it once I do.



</head>

<body background="newdesertbg2.jpg" topmargin="0" leftmargin="0" bgproperties="fixed">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100" rowspan="3" valign="top">
<center>
<img src="test33.gif">
</td>
<td height="425">
<div id="illypic1" class="imgfader">
<table width="820" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="425">
<center>
<img src="illyanaone.jpg" alt="Desert Queen of the Snakes">
</center>
</td>
</tr>
</table>
</div>
<div id="illypic2" class="imgfader">
<table width="820" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="425">
<center>
<img src="illyanatwo.jpg" alt="Snakes aren't her only pets.">
</center>
</td>
</tr>
</table>
</div>
<div id="illypic3" class="imgfader">
<table width="820" cellpadding="0" cellspacing="0" border="0">
<tr>
<td height="425">
<center>
<img src="illyanatre.jpg" alt="The Consumation of her love for the Desert King.">
</center>
</td>
</tr>
</table>
</div>
</td>

<script type="text/javascript" charset="ISO-8859-1">
<!--
function initializeview()
{
document.getElementById("illypic2").style.filters.alpha.opacity=1
document.getElementById("illypic3").style.filters.alpha.opacity=1
}
initializeview()
-->
</script>

Unless I am just terribly missing something obvious, the highlighted function should dial the opacity of the elements in question down to nothing more than the barest hint of a ghost image. However, it does nothing of the sort and I don't understand why. I have seen similar scripts on other web sites and they seem to have no problem what so ever, but for some reason it is simply not working for me. If anyone has any clue, I am all ears. . .

GW



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum