0

I am trying to manipulate elements outside of iframe by setting JS inside of my iframe The style.backgroundColor code works but not innerHtml

I have

<script type="text/javascript"> 
           //get main document element.
           var ititle= parent.document.getElementById('MainTitle');
           //works          
           ititle.style.backgroundColor = "#FFCC00";
       //doesn't work
       ititle.innerHtml='test html';
</script>  

The above script is inside my iframe

Are there any reasons why? Thanks a lot.

Rouge
  • 4,181
  • 9
  • 28
  • 36
  • It shouldn't be `innerHTML` ? https://developer.mozilla.org/en-US/docs/DOM/element.innerHTML – Marcelo Assis Sep 11 '12 at 20:33
  • Also take a look at this: http://stackoverflow.com/questions/5604839/accessing-an-element-outside-of-iframe – mishmash Sep 11 '12 at 20:34
  • Possible duplicate of [Accessing an element outside of iframe](https://stackoverflow.com/questions/5604839/accessing-an-element-outside-of-iframe) – user1937198 Sep 02 '19 at 19:13

1 Answers1

3

Because JavaScript is CaseSensitive, and it's innerHTML (all uppers):

 ititle.innerHtml='test html';
 //should be
 ititle.innerHTML='test html';
Elias Van Ootegem
  • 74,482
  • 9
  • 111
  • 149
  • ok. that was dumb. Thanks a lot! – Rouge Sep 11 '12 at 20:35
  • You're welcome, we've all been there. I've asked a huuuuge question here once, only to see the syntax highlighting applied just after I posted it, and realize that I had forgotten an apostrophe somewhere :) – Elias Van Ootegem Sep 11 '12 at 20:38