We help IT Professionals succeed at work.
Get Started

Javascript from IFrame write to DIV in page

jayh99 asked
Last Modified: 2008-01-09
Can someone help me writing from an IFRAME to the div in my parent page.  I am trying the code below, but I get a js error when it runs.  I am guessing that if it is possible, the error is in the document.getElementById(id);.  The script is in my IFRAME, and the DIV is in my parent page.  Thanks in advanced for the help.  

function writit(text,id)
      if (document.getElementById)
            x = document.getElementById(id);
            x.innerHTML = '';
            x.innerHTML = text;
      else if (document.all)
            x = document.all[id];
            x.innerHTML = text;
      else if (document.layers)
            x = document.layers[id];
            text2 = '<P CLASS="testclass">' + text + '</P>';
Watch Question
IT Manager
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE