gpt4 book ai didi

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

转载 作者:技术小花猫 更新时间:2023-10-29 12:31:04 24 4
gpt4 key购买 nike

如何在警告框或确认框中显示图像?我一直在尝试使用以下代码,但在警告框中获取图像 url。请任何人帮助我解决问题,或者如果不可能,请提出任何其他建议。

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

最佳答案

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>

关于javascript - 如何在 Javascript 的警告/确认框中显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19659173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com