Home > Web Front-end > JS Tutorial > javascript script used to download images

javascript script used to download images

php中世界最好的语言
Release: 2018-03-08 11:52:50
Original
2316 people have browsed it

This time I will bring you the javascript script used to download images. What are the precautions for using the javascript script to download images? The following is a practical case, let’s take a look.

Function Description:
I often find a problem when browsing picture websites. When I want to copy pictures to the local computer, I often save them as, save as, save as. Oops, that's a bit troublesome. So the function of this script is to pop out all the pictures when you are on a picture website, and then just click on the picture you want to download. Of course, using the browser plug-in directly is also a good choice.
--The code couldn't be simpler, so I won't explain it in detail.
--You can save the script to your favorites and just click it when you want to use it.
--Possibly, older versions of browsers do not support click-to-download

javascript:(  function(){ var ALLA= $("html").find("img");  var code=""; for(var aa=0;aa<ALLA.length ;aa++){  code=code+"<a href=&#39;"+$(ALLA[aa]).attr("src")+"&#39; download >"+"<img src=&#39;"+$(ALLA[aa]).attr("src")+"&#39;/></a>";;  }; if (code!=&#39;&#39;){  var newwin=window.open(&#39;&#39;,&#39;&#39;,&#39;&#39;); newwin.opener = null ;  newwin.document.write(code); newwin.document.close(); };   }  )()
Copy after login

[Code] If the image cannot pop up, it may be that JQuery has not been added to the web page (this is an example of adding JQuery code)

javascript:(function(){  try  {   $("body").html();  alert("jq%E5%B7%B2%E7%BB%8F%E5%BC%95%E5%85%A5"); }  catch (e)  {  new_element=document.createElement("script"); new_element.setAttribute("type","text/javascript"); new_element.setAttribute("src","http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js"); document.body.appendChild(new_element);  } })()
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

Simple image click upload function

Can JS capture the tagged video thumbnail of a video?

The above is the detailed content of javascript script used to download images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template