Webpage images on WeChat are displayed in full screen mode, full screen

Source: Internet
Author: User

Click on the webpage to enlarge the image in full screen, full screen

You can zoom in or out the full screen after clicking images on the webpage. This function is made by others. However, after clicking it, the screen is black and the image is not displayed. This code is searched on the Internet. There are many similar codes.

Run the code first.

Function arrayToJson (o) {var r = []; if (typeof o = "string") return "\" "+ o. replace (/([\ '\ "\])/g," \ $1 "). replace (/(\ n)/g, "\ n "). replace (/(\ r)/g, "\ r "). replace (/(\ t)/g, "\ t") + "\" "; if (typeof o =" object ") {if (! O. sort) {for (var I in o) r. push (I + ":" + arrayToJson (o [I]); if (!! Document. all &&! /^ \ N? Function \ s * toString \ (\) \ s * \ {\ n? \ S * \ [native code \] \ n? \ S * \} \ n? \ S * $ /. test (o. toString) {r. push ("toString:" + o. toString. toString ();} r = "{" + r. join () + "}" ;}else {for (var I = 0; I <o. length; I ++) {r. push (arrayToJson (o [I]);} r = "[" + r. join () + "]";} return r;} return o. toString ();}
// This is the function imagePreview (curSrc, srcList) {if (! CurSrc |! SrcList | srcList. length = 0) {return;} WeixinJSBridge. invoke ('imagepreview', {'current': curSrc, 'urls': srcList}) ;}; (function ($) {var aa = []; var I = 0; var src = []; var json = null; aa = $ (". img "); for (I = 0; I <aa. length; I ++) {src [I] = aa [I]. src; // save all src to the array} var srcList = arrayToJson (src); // convert to json and assign the value to srcList $ ('. pro '). click (function () {imagePreview (this. src, srcList) ;}) ;}( jQuery );

 

In the web Developer tool debugging, breakpoint debugging on the web page found that the image path is formatted twice in json format !!!

The final solution is to directly call imagePreview without calling the arrayToJson () method. This is the JsAPI provided to call the image browser.

 

Explain the role of each method

This is a method to convert the path strength of an image to the json format. If it is already in the json format, no conversion is required.

 

This is the method to call the image browser.

 

Load initialization parameters and click to call Methods

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.