小编典典

如何在Javascript的“警报/确认”框中显示图像?

css

如何在警告框或确认框中显示图像?我一直在尝试下面的代码,但在警告框中获取图像URL。请任何人帮助我获得解决,或者如果无法解决,请提出其他建议。

var image = document.getElementById("myImage").src="hackanm.gif";
alert("OnLoad image"+image );

阅读 261

收藏
2020-05-16

共1个答案

小编典典

JavaScript中的警报框只能显示纯文本。您可以使用jQuery之类的JavaScript库来显示模式吗?

您可以这样做:

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <script>
  body {
    font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
    font-size: 62.5%;
}

  </script>
  <script>
  $(function() {
    $( "#dialog" ).dialog();
  });
  </script>
</head>
<body>

<div id="dialog" title="Basic dialog">
  <p>Image:</p>
  <img src="http://placehold.it/50x50" alt="Placeholder Image" />

</div>


</body>
</html>
2020-05-16