请问跳转问题

下面这样,那个图片不会显示。

img src

<script>window.location.href=
();</script>

请问怎样才能在跳转前显示图片?

我的意思是一个页面上既要显示图片,又要跳转。

阅读 1k
1 个回答
const showImageBeforeRedirect = (image) => {
  if(!image) throw new Error("image can't be null")
  image.onload = image.onerror = () => {
    window.location.href = "redirectUrl"
  }
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题