JavaScript执行document.write()原有控件消失

1585364631
2022-03-03 / 0 评论 / 425 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年03月05日,已超过1469天没有更新,若内容或图片失效,请留言反馈。

JavaScript执行document.write()原有控件消失

<!DOCTYPE html>
<html>
    <meta charset="utf8">
    <body>
        <input type="button" value="点我" onclick="document.write('按钮消失')" style="position: absolute;width: 200px;height: 100px;left: 0;right: 0;top: 0;bottom: 0;;margin: auto;">
    </body>
</html>

document.write()执行时,将重写当前页面,原有内容全部消失,只会留下document.write()所写内容

0

评论 (0)

取消