...

View Full Version : Static Page Element Problem



greasonwolfe
11-09-2004, 08:09 PM
Okay, here is the deal, I have used/seen this script before (or something very similar to it) on other pages and it seems to work just fine. However, I am getting a "null or void object" error at the highlighted point using IE. Did I just absolutely miss something, or is there a reason for it to come up this way? I am also not getting the table width adjustment I had hoped for so any insight along those lines would be helpful as well.

<script language="javascript">
var floatobj=document.all? document.all.rollcorner : document.getElementById? document.getElementById("rollcorner") : document.rollcorner
var tableobj=document.all? document.all.storyboard : document.getElementById? document.getElementById("storyboard") : document.storyboard

var movetop=0
var moveleft=0

function moveit()
{
var floatleft=document.all? document.body.scrollLeft : pageXOffset
var floattop=document.all? document.body.scrollTop : pageYOffset
if (movetop<<floattop) {movetop=movetop+1}
else {movetop=movetop-1}
if (moveleft<<floatleft) {moveleft=moveleft+1}
else {moveleft=moveleft-1}
if (document.all||document.getElementById)
{
floatobj.style.left=moveleft+2
floatobj.style.top=movetop+2
}
else if (document.layers)
{
floatobj.left=moveleft+2
floatobj.top=movetop+2
}
moveit()
}

function settable()
{
var window_width=document.all? document.body.clientwidth : window.innerwidth
tableobj.width=parseInt(window_width)-260
}

window.onResize=settable()
</script>


I have the DIV in question defined in the body of the html and am using the onload event to call the functions. Again, any insight would be helpful before I throw my comp out the window in frustration.

Roy Sinclair
11-09-2004, 08:25 PM
Find where you've defined something on your page and given it an ID or NAME of "layers", change that to a valid name that won't cause IE to think that "document.layers" is a valid object because that code is there to check for Netscape 4 browsers.

greasonwolfe
11-09-2004, 08:37 PM
I havent given anything an ID or NAME of "layers". As I understood it when I was going through various tutorials and what not, that bit of code was supposed to pick up the slack and move the element on older versions of netscape, though I may have misinterpreted that. The only elements I have named are the following. . .

<div name="rollcorner" style="width:255px;height:565px;position:absolute;visibility:visible;top:0px;left:0px">
<img src="greasoncorner.jpg" name=greacorner" width="255" height="565" alt="Greason Wolfe">
</div>
<table name="storyboard" border="0" cellpadding="0" cellspacing="0" align="right" width="100%">

greasonwolfe
11-09-2004, 09:18 PM
I am going to start over with this and post the full of the source code so that anyone trying to help me out will be able to see everything I have done. I did make a few minor changes from what I had before and it seems to have cleared all the errors until it gets to the body tage where it comes up with an "object expected" error. As I said, I have used code very similar to this before, but it is my first attempt at writing it on my own as opposed to cutting and pasting from DD or JSK.



<html>
<head>
<title>Greason Nightwolfe</title>
<script language="javascript">

var floatobj=document.all? document.all.rollcorner : document.getElementById? document.getElementById("rollcorner") : document.rollcorner
var tableobj=document.all? document.all.storyboard : document.getElementById? document.getElementById("storyboard") : document.storyboard

var grearoll=new Image(255,565)
var morroll=new Image(255,565)
var tailroll=new Image(255,565)
grearoll.src="greasoncorner.jpg"
morroll.src="moraxcorner.jpg"
tailroll.src="tailcorner.jpg"

var movetop=0
var moveleft=0

function moveit()
{
var floatleft=document.all? document.body.scrollLeft : docuement.getElementById? pageXOffset
var floattop=document.all? document.body.scrollTop : document.getElementById? pageYOffset
if (movetop<<floattop) {movetop=movetop+1}
else {movetop=movetop-1}
if (moveleft<<floatleft) {moveleft=moveleft+1}
else {moveleft=moveleft-1}
if (document.all.rollcorner||document.getElementById("rollcorner"))
{
floatobj.style.left=moveleft+2
floatobj.style.top=movetop+2
}
else if (document.rollcorner)
{
floatobj.left=moveleft+2
floatobj.top=movetop+2
}
moveit()
}

function settable()
{
var window_width=document.all? document.body.clientWidth : window.innerWidth
tableobj.width=parseInt(window_width)-260
}

window.onResize=settable()

</script>
</head>

<body bgcolor="#000000" margintop="0" marginleft="0" onLoad="moveit();settable()">

<div name="rollcorner" style="width:255px;height:565px;position:absolute;visibility:visible;top:0px;left:0px">
<img src="greasoncorner.jpg" name=greacorner" width=255 height=565 alt="Greason Wolfe">
</div>

<table name="storyboard" border="0" cellpadding="0" cellspacing="0" align="right" width="100%">
<tr>
<td background="pagetopleft.jpg"></td><td background="pagemid.jpg"></td><td background="pagetopright.jpg"></td>
</tr>
<tr>
<td colspan="3" background="pagemid.jpg">
<font face="calisto" color="#ffffff" size="3">
</font>
</td>
</tr>
<tr>
<td background="pagebotleft.jpg"></td><td background="pagemid.jpg"></td><td background="pagebotright.jpg"></td>
</tr>
</table>
</body>
</html>


I am at a complete loss with this one. At this point, I am not even worried about dealing with the table dimensions. I would be happy just to get the floating element on the move right now.

Roy Sinclair
11-09-2004, 09:30 PM
var floatleft=document.all? document.body.scrollLeft : docuement.getElementById? pageXOffset
var floattop=document.all? document.body.scrollTop : document.getElementById? pageYOffset


Both these lines are also incomplete.

greasonwolfe
11-09-2004, 10:17 PM
Gah. . . okay, so I cant spell sometimes. . . and um. . . what exactly do you mean by incomplete?

Roy Sinclair
11-09-2004, 10:47 PM
Incomplete as in the statements aren't completed. You're missing the final ":" and javascript statement on each of those lines that are required to complete the second ternary operation.

greasonwolfe
11-11-2004, 09:33 AM
Okay, I am taking another look at things and backing up a step or two. . I found a way to get the script working, but dont like the results very much just yet, so I am back at the drawing board so to speak. But your advice has been helpful, so thanks bunches for it.

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum