我有一个名为<div class="v7-music-detail-news">
的div。但我想再次添加div并在一个新div中添加脚本,但页面什么也没显示。请帮助我在剧本中遗漏的内容。
这是我的剧本:
<script type="text/javascript">
var div = document.createElement('div');
div.className = 'survey_frame';
div.id = 'survey_frame';
var script = document.createElement("script");
script.type = "text/javascript";
script.text = "(function(d, h, s) {\
var cont = d.getElementById('survey_frame_zLBexnZW');\
var ifrm = d.createElement('iframe');\
ifrm.src = 'http://www.someurl.com';\
ifrm.style.width = '100%';\
ifrm.style.height = '200px';\
ifrm.setAttribute('scrolling', 'no');\
ifrm.setAttribute('frameborder', '0');\
cont.appendChild(ifrm);\
if (typeof iFrameResize == 'undefined') {\
var ch = d.getElementsByTagName(h)[0];\
js = d.createElement(s);\
js.type = 'text/javascript';\
js.src = 'http://www.someurl.com/iframeResizer.min.js';\
ch.appendChild(js);\
js.onload = iframe_resize;\
} else {\
iframe_resize();\
}\
function iframe_resize() {\
iFrameResize({\
log: true\
}, '#survey_frame');\
}\
}(document, 'head', 'script'));";
div.appendChild(script);
document.getElementById('v7-music-detail-news').appendChild(div);
}
</script>
这里是我的div:
<div class = "v7-music-detail-news">
<!-- Here I want To Append new div and my script inside new div -->
</div>