dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Unknown Runtime Error InnerHTML

  1. #1
    Join Date
    Jul 2010
    Posts
    4

    Unknown Runtime Error InnerHTML

    Hello everyone:

    Okay, I have thoroughly researched this out and I was able to see many examples of this error, however the scenarios were not similar enough to my example and although I learned that this error is caused by trying to place a block level element into an inline element, I am not able to fix it myself.

    It may not be all difficult to fix, but I am new to this and just learning so for me it's rather frustrating at the moment. This script does work in Firefox.

    The offending line seems to be #17:
    parent.document.all[19].innerHTML=str;

    The script is a slide show, it features a timer which you can turn on or off the scrolls through the images automatically. However if you wish to see the images manually, the script uses an array and each image has a button in the form to manually scroll through the images;

    I hope this helps.


    <HTML><HEAD>
    <title>JS.Lab: Slide Show: [ jslab.tripod.com ]</title>
    <SCRIPT LANGUAGE='JavaScript1.2'>
    <!-- Hide the script from old browsers -->
    Slide = new Array();
    Im="image";
    imagenum = new Array("0.jpg","1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg");
    var Speed = 4000;
    var N = 1, Max_N = 9, N0=0, N1=1;
    for (i=0; i <= Max_N; i++)
    {
    Slide[i]=new Image; Slide[i].src=Im+imagenum[i];
    }
    function S(n){
    N0=N1;N1=n;
    str ="<IMG SRC='"+Im+n+".jpg' border=0>";
    parent.document.all[19].innerHTML=str;
    parent.document.all[N0+8].style.color="#000000";
    parent.document.all[N1+9].style.color="#ff0000";
    }
    function Load(){
    parent.document.all[19].innerHTML="<IMG SRC='image0.jpg' border=0>";
    }
    function Start(){
    S(N);
    N++;
    if (N >= (Max_N+1)) N = 1;
    timerID = setTimeout("Start()",Speed);
    }
    function Stop(){
    clearTimeout(timerID);
    }
    <!-- Hide the script from old browsers -->
    </SCRIPT>
    <style type="text/css">
    DIV{
    border-width:8px;
    border-color:cccccc;
    border-style:ridge;
    background-color:transparent;
    width:10%;
    color:red;
    }
    </style>
    </HEAD>
    <BODY bgcolor="#ffffcc" onload="Load()">
    <center>

    <form name="F1">
    <input type=button value=" 0 " onclick="S(0)"><input type=button value=" 1 " onclick="S(1)"><input type=button value=" 2 " onclick="S(2)"><input type=button value=" 3 " onclick="S(3)"><input type=button value=" 4 " onclick="S(4)"><input type=button value=" 5 " onclick="S(5)"><input type=button value=" 6 " onclick="S(6)"><input type=button value=" 7 " onclick="S(7)"><input type=button value=" 8 " onclick="S(8)">
    <input type=button value="Start" onclick="Start()"><input type=button value="Stop" onclick="Stop()">
    </form>
    <div>Load images...</div>
    <form name="F2">
    <input name=B1 type=button value="Home" onclick="parent.document.location ='http://www.somewhere.com'">
    </form>
    </center>
    </BODY>
    </HTML>

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    this error is caused by trying to place a block level element into an inline element
    That is invalid and can only be corrected by placing an inline element in an inline element.

    document.all only works in IE

    The script used is very old. There are many new image gallery scripts on the web.

  3. #3
    Join Date
    Jul 2010
    Posts
    4

    unknown runtime error.

    What I don't understand is that when you load the page, the first image loads into the <div></div> tags, in other the words the script pieces together the string and passes it to the divide and the image is displayed. So why does it not work the after that?

    The script assembles a string from the variables, this point to an actual image, that is passed to an <div></div> I realize the <div> is a block element and that the <img> is an line element. what is the alternative, I like to keep the over essence of this script, but not sure what the string should be loaded into, since we cannot use a divide.

    Anyone have an idea how I can modify this to work? I would rather keep using this script if possible.

    TIA

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    You will have to post the parent document as well.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles