Link to home
Start Free TrialLog in
Avatar of fidoly
fidoly

asked on

Document write to Iframe problem

I am seeing a particular problem in a script I have.  The script will write to an iframe 3 different values, one at a time, a click of an arrow will write the next item or back up an item.  For some reason the browser does not show #2. .

Here is a skimmed down version of the script:

        var theHI = 0;

        function forwardOne(){
              theHI = theHI + 1;
              window.frames.iHot.location = 'about:blank';
              showHotItem(theHI);
        }
        function backOne(){
              theHI = theHI - 1;
              window.frames.iHot.location = 'about:blank';
              showHotItem(theHI);
        }


        function showHotItem(HI) {
                    var i = frames["iHot"];
                  i.document.write('<html><body>');
                  if(HI == 1){i.document.write('ITEM 1')};
                  if(HI == 2){i.document.write('ITEM 2')};
                  if(HI == 3){i.document.write('ITEM 3')};
                  i.document.write('</body></html>');
        }

The HTML:

<iframe name="iHot" id="iHot" src=""></iframe>
<img src=right-arrow.gif onClick=forwardOne();>
<img src=left-arrow.gif onClick=backOne();>

Do you see what could be wrong? Or could I approach this in a different way?

Many thanks,

FR.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fidoly
fidoly

ASKER

Worked quite well!  Thanks a MEG!