为了账号安全,请及时绑定邮箱和手机立即绑定

请问在<script>标签里面能再包含<script>标签了吗?

请问在<script>标签里面能再包含<script>标签了吗?

为什么显示的位置不对啊?怎么设置啊?您能具体说说么?
查看完整描述

1 回答

?
慕码人2483693

TA贡献1860条经验 获得超9个赞

可以的,需要把 </script>改为 <\/script>;例如:
<html>
<head>
<script type="text/javascript">
function createNewDoc()
{
var txts="";
var newDoc=document.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!\
<input type='button' value='dynamic response'/> \
<script> function warning(){ alert(\"new document\");}\
document.getElementsByTagName('input')[0].addEventListener('click',warning);\
<\/script><\/body><\/html>";

console.log(txt);
newDoc.write(txt);
newDoc.close();
}
</script>
<body>
<input type="button" value="Write to a new document"
onclick="createNewDoc()">

</body>
</html>



查看完整回答
反对 回复 2022-03-15
  • 1 回答
  • 0 关注
  • 801 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号