有什么方法可以使用onload函数在图像上加载文本?

问题描述 投票:0回答:1

我已经在网页背景中使用了图片。现在我想要的是,在加载整个图像之后,应该在同一文档上记录文本。为此,到目前为止,我已经完成了以下操作:-

<body onload = "myFunction()">
<script>
function myFunction() {
  setTimeout(function(){ document.write("<h1>H"); }, 1000);
  setTimeout(function(){ document.write("E"); }, 2000);
  setTimeout(function(){ document.write("L"); }, 3000);
  setTimeout(function(){ document.write("L"); }, 4000);
  setTimeout(function(){ document.write("O</h1>"); }, 5000);
}
</script>
</body>

上面的方法在没有图像的情况下也可以正常工作,但是在应用于图像时根本不会加载。

javascript html css image dom
1个回答
0
投票

尝试在正文标签中使用图像属性

© www.soinside.com 2019 - 2024. All rights reserved.