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

Mal*_*jun 13 html javascript css

如何在警告框或确认框中显示图像?我一直尝试使用下面的代码,但在警告框中获取图像网址.如果不可能,请任何人帮我解决或请提出任何其他建议.

var image = document.getElementById("myImage").src="hackanm.gif";
alert("OnLoad image"+image );
Run Code Online (Sandbox Code Playgroud)

Lon*_*Dev 9

JavaScript中的警告框只能显示纯文本.您可以使用像jQuery这样的JavaScript库来显示模态吗?

这可能很有用:http: //jqueryui.com/dialog/

你可以这样做:

<!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>
Run Code Online (Sandbox Code Playgroud)


lil*_*shu 7

Snarky但可能有用的答案:http: //picascii.com/ (别忘了在每一行之后放一个\n!)