gpt4 book ai didi

javascript - 如何将页面中的图像保存到文件夹

转载 作者:行者123 更新时间:2023-12-03 02:05:24 25 4
gpt4 key购买 nike

我的index.html 页面中有一张图像。我希望 javascript 或 jquery 通过单击按钮自动将此图像下载到我的文件夹中。

<!DOCTYPE HTML>
<html>
<head>
<title>save image from a page</title>
</head>

<body>

<img src="car.jpg"/>
<button>save Image in my folder</button>
<!-- the name of the folder is : (saveImage) : and it is in the same
place with my index.html-->

<script src="jquery-1.11.3.min.js"></script>
<script>
$("button").click(function()
{
// download image from the index.html to my folder (saveImage)
});
</script>

</body>
</html>

最佳答案

我尝试跟随并用 Firefox 和 Chrome 检查它。两种浏览器都运行良好。在您的链接中使用了 HTML5“下载”属性。

<!DOCTYPE HTML>
<html>
<head>
<title>save image from a page</title>
</head>
<body>
<a style="display:none;" href="car.png" download>save Image in my folder </a>
<img src="car.png"/>
<!-- the name of the folder is : (saveImage) : and it is in the same
place with my index.html-->
<button>save Image in my folder</button>
<script src="jquery-1.11.3.min.js"></script>
<script>
$("button").click(function()
{
$('a')[0].click();
});
</script>
</body>
</html>

关于javascript - 如何将页面中的图像保存到文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49835846/

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