?
Solved

Document write to Iframe problem

Posted on 2007-10-02
2
Medium Priority
?
893 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:fidoly
2 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 20000389
Add document.close();

Like this:

        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>');
                  i.document.close();
        }



0
 

Author Comment

by:fidoly
ID: 20000694
Worked quite well!  Thanks a MEG!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question