SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript scrollbar problem - runtime error

    a runtime error has occurred

    line 95
    error: object required

    and the line 95 is

    <code>

    this.el = (ns4)? (nest)? document.layers[nest].document.layers[obj]: document.layers[obj]: (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;

    </code>

    but...the debugger says something about variable i already defined...

    <code>

    for (var i=0; i<wndo.length; i++) {

    </code>



    everything else seems to be working fine.aparto from the irritating message...

    and...the whole code is here:

    <code>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- saved from url=(0035)http://your.workcomms.com/test.html -->
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1250">
    <STYLE>#wndo1 {
    Z-INDEX: 4; LEFT: 30px; OVERFLOW: hidden; WIDTH: 500px; CLIP: rect(0px 500px 230px 0px); POSITION: absolute; TOP: 180px; HEIGHT: 230px
    }
    .content {
    LEFT: 0px; POSITION: absolute; TOP: 0px
    }
    #divUpControlMain {
    Z-INDEX: 4; LEFT: 550px; WIDTH: 20px; POSITION: absolute; TOP: 180px; HEIGHT: 20px
    }
    #divDownControlMain {
    Z-INDEX: 4; LEFT: 550px; WIDTH: 20px; POSITION: absolute; TOP: 390px; HEIGHT: 20px
    }
    </STYLE>

    <SCRIPT language=JavaScript type=text/javascript>

    /*
    scroll-multi.js

    */

    dom = (document.getElementById) ? true : false;
    ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
    ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
    ns4 = (document.layers && !dom) ? true : false;
    ie4 = (document.all && !dom) ? true : false;
    nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

    var inc = 4; // controls speed of scroll (larger number for faster scroll)
    var timer = 20; // interval between calls to scroll onmouseover
    var t=0; // for setTimeouts

    var done;
    wndo = new Array(); // for window layers
    cntLyrs = new Array(); // for scrolling content areas

    function getLyrTop() { return parseInt(this.css.top); }
    function getLyrLeft() { return parseInt(this.css.left); }

    function shiftTo(x,y) {
    if (ns4) { this.css.moveTo(x,y); }
    else { this.css.left=x+"px"; this.css.top=y+"px"; }
    }

    function shiftBy(x,y) {
    if (ns4) { this.css.moveBy(x,y); }
    else {
    this.css.left = parseInt(this.css.left)+x+"px";
    this.css.top = parseInt(this.css.top)+y+"px";
    }
    }

    function inchRight(num) {
    if (!done) return; var y = cntLyrs[num].getLeft();
    if (y>-maxX[num]) {
    cntLyrs[num].shiftBy(-inc,0);
    //cntLyrs[num].css.left=parseInt(cntLyrs[num].css.left)-inc;
    t = setTimeout("inchRight('"+num+"')",timer);
    }
    }

    function inchLeft(num) {
    if (!done) return; var y = cntLyrs[num].getLeft();
    if (y<0) {
    cntLyrs[num].shiftBy(inc,0);
    t = setTimeout("inchLeft('"+num+"')",timer);
    }
    }

    function inchDown(num) {
    if (!done) return; var y = cntLyrs[num].getTop();
    if (y>-maxY[num]) {
    cntLyrs[num].shiftBy(0,-inc);
    t = setTimeout("inchDown('"+num+"')",timer);
    }
    }

    function inchUp(num) {
    if (!done) return; var y = cntLyrs[num].getTop();
    if (y<0) {
    cntLyrs[num].shiftBy(0,inc);
    t = setTimeout("inchUp('"+num+"')",timer);
    }
    }

    ////////////////////////////////////////////////////////////////////
    // Constructor function used for creating scrollable content areas.
    // Used to create both wndo and content objects.
    ////////////////////////////////////////////////////////////////////
    function createObj(obj,nest,id) {
    this.el = (ns4)? (nest)? document.layers[nest].document.layers[obj]: document.layers[obj]: (ie4)? document.all[obj]: (ie5||ns5)? document.getElementById(obj): null;
    this.css = (ns4)? this.el: (ie4||ie5||ns5)? this.el.style: null;
    this.height = (ns4)? this.el.clip.height: (ie4||ie5)? this.el.clientHeight: (ns5)? this.el.offsetHeight: 0;
    this.width = (ns4)? this.el.clip.width: (ie4||ie5)? this.el.clientWidth: (ns5)? (id)? document.getElementById(id).offsetWidth: this.el.offsetWidth: 0;
    this.getLeft = getLyrLeft; this.getTop = getLyrTop;
    this.shiftBy = shiftBy; this.shiftTo = shiftTo;
    }


    </SCRIPT>

    <SCRIPT language=JavaScript type=text/javascript>
    <!--
    /*
    This code is from Dynamic Web Coding
    www.dyn-web.com
    Copyright 2001 by Sharon Paine
    Permission granted to use this code as long as this
    entire notice is included.
    */

    dom = (document.getElementById) ? true : false;
    ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
    ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
    ns4 = (document.layers && !dom) ? true : false;
    ie4 = (document.all && !dom) ? true : false;
    nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

    var origWidth, origHeight;
    if (ns4) {
    origWidth = window.innerWidth; origHeight = window.innerHeight;
    window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
    }

    function initObjs() {
    /////////////////////////////////////////////////////////////
    // Argument for creating wndo objects: id of wndo div.
    // Arguments for creating content:
    // id of content div, id of its wndo div (div it is nested in),
    // id of table or other html element that contains content.
    // NOTE: Netscape 6 needs that html container and its id
    // in order to get width for horizontal scrolling.
    // If only using vertical scrolling, that extra container
    // is not necessary.
    /////////////////////////////////////////////////////////////

    // first scrollable content area
    wndo[0] = new createObj('wndo1');
    cntLyrs[0] = new createObj('cnt1_1','wndo1');



    /////////////////////////////////////////////////////////////////////
    // Don't remove these lines
    // set left, top to 0,0 (necessary for all but ns4 to get top,left)
    for (var i=0; i<cntLyrs.length; i++){
    cntLyrs[i].shiftTo(0,0);
    }
    // to keep track of distance to scroll
    maxX = new Array(); maxY = new Array();
    for (var i=0; i<wndo.length; i++) {
    maxX[i] = cntLyrs[i].width - wndo[i].width;
    maxY[i] = cntLyrs[i].height - wndo[i].height
    }
    done = true; // ready
    }

    window.onload = initObjs;

    //-->
    </SCRIPT>

    <META content="MSHTML 6.00.2716.2200" name=GENERATOR></HEAD>
    <BODY bgcolor="#54585C">
    <table width="100%" border="0" callpadding = 0 cellspacing= 0 height="100%" cellpadding="0">
    <tr>
    <td align="left" valign="top" height="616">
    <table width="306" border="0" cellpadding="0" cellspacing="0" height="238">
    <tr bgcolor="#FFFFFF">
    <td width="41%">&nbsp;</td>
    <td width="0%">&nbsp;</td>
    <td width="9%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td width="41%">&nbsp;</td>
    <td width="0%">&nbsp;</td>
    <td width="9%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td width="41%">&nbsp;</td>
    <td width="0%">&nbsp;</td>
    <td width="9%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td width="41%">&nbsp;</td>
    <td width="0%">&nbsp;</td>
    <td width="9%">&nbsp;</td>
    </tr>
    <tr bgcolor="#FFFFFF">
    <td width="41%">&nbsp;</td>
    <td width="0%">&nbsp;</td>
    <td width="9%">&nbsp;</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </BODY></HTML>

    </code>

    please help.

    check it out at: http://www.inet.hr/~osvlan02/
    Last edited by tRe; Dec 25, 2002 at 13:37.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    solved

    thanks anyway....

  3. #3
    Froot r gewd SubKamran's Avatar
    Join Date
    May 2002
    Location
    North Star State
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Offtopic:

    Next time you submit a question, please enclose your code like this:

    Code:
    [ code ]CODE[ /code ]
    With no spaces between the brackets.
    "Sometimes little is more."
    Kamran A
    Web Dev/Designer
    Keyboard not found: Please Press F1 to Continue


Bookmarks

Posting Permissions

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