Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Question Static Page Element Problem

    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.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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%">

  • #4
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #6
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Gah. . . okay, so I cant spell sometimes. . . and um. . . what exactly do you mean by incomplete?

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #8
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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.



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •