I'm calling a third party script tag inside a div. This third party js renders an iframe & puts their content inside the div I put this tag into. However I see the iframe but the head & body of iframe does not have anything in it, Seems js is not getting executed properly & hence I cannot see the content inside the div. I can just see the iframe being generated & appended to the div but cannot see any content inside it. This is how I have placed the third party tag.( PS Basically the third party script tag pulls the value of property "abc" of object1 & executes. )
html file:
< div id= "div2" style="display:none" >
< script >
var object1 = {
abc: "this is a fruit"
};
< /script>
<script type="text/javascript" src="thirdpartyjscode.js"></script>
< /div >
js file:
$('#div1').append($('#div2').show());
This code would show me div2 inside div1 but and the script inside div2 does get evealuated & I see iframe appended to div2 but I dont see any content inside it . Why would this happen? I don't get it. I read maybe using eval() would help but I'm not quite sure
This is what content looks like in the console after I do this & then I console logged "content"
var content = $('#div2').detach().html();
$('#div1').append('<div>', {
id: 'div2',
html: content
});
console.log(content) gives me the below .. But I dont see that iframe appended to the div2
<script type="text/javascript">
var object1 = {
abc: "this is a fruit"
};
</script>
<script type="text/javascript" src="thirdpartyjscode.js"></script><iframe id="abc_61086936097182" src="" width="610" height="100%" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" style="display: block; height: 871px;"></iframe>