# javaScript in innerHTML

**URL:** <https://forum.kirupa.com/t/javascript-in-innerhtml/330710>\
**Category:** web dev\
**Created:** [March 4, 2013, 9:28pm UTC](https://forum.kirupa.com/t/javascript-in-innerhtml/330710 "2013-03-04T21:28:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [March 4, 2013, 9:28pm UTC](https://forum.kirupa.com/t/javascript-in-innerhtml/330710/1 "2013-03-04T21:28:58Z")

</div>

Hi all,  
I’m working on an if else function and in the if part I have an javascript and html that I want to use in case but the innerHTML is not working can anyone help?

here is part of the code i’m using…

```auto

function(){
      var myHTML = ' ';
if (my_condition){
        myHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="720" height="480" id="_mp4" align="middle">';
        myHTML = ' <object type="application/x-shockwave-flash" data="_mp4.swf" width="720" height="480">';
        myHTML = ' <param name="movie" value="_mp4.swf" />';
        myHTML = ' <param name="quality" value="high" />';
        myHTML = ' <param name="allowScriptAccess" value="sameDomain" />';
        myHTML = ' </object>';
        myHTML = '</object>';
        } else {
// the rest of my code!
}
window.onload = (document.getElementById("my_div").innerHTML = myHTML);
})();

```

tks a lot in advance!
