This article describes how jssdk solves the problem on the iframe page. For more information, see
Project requirements
The photo upload function is available on the page for adding a photo. An iframe is opened during the upload. The image selected by the jssdk selection image interface is loaded using the canvas. (here, a picture, such as weixin, is returned: // The localid of xxxx, which can be directly previewed in the src of img). You can zoom in, zoom in, rotate, and other operations. Click OK to send the edited image to the server and save it as an image.
Problems encountered
After the sub-page function is developed, you can open the sub-page through iframe on the home page. You cannot call the select image interface in the jssdk interface, and the interfaces in other jssdk cannot work normally. However, opening the sub-page can work normally, and sharing on the home page is also normal.
Solution
First, jssdk signature information is injected to the primary and subpages simultaneously to determine whether conflicts may occur. This possibility was ruled out after testing. Through the network search, some netizens described in this post the problem is similar to me, but there is no solution to http://www.weixin.com/thread-8022-1-1.html
Through the test, you can perform signature verification on the homepage without adding the signature information of jssdk to the subpage. When you need to call the jssdk interface, add parent. Before the jssdk function, that is, call the function on the parent page. After testing, the function can be called normally.
Parent. wx. chooseImage ({success: function (res) {// upload_success (res. localIds );}
It is worth mentioning that jssdk seems to be powerful, but has a lot of bugs. It is really used in projects and cannot be inferred. Although this problem is solved, the new problem arises again, and the canvas export image cannot be cross-origin... In the end, no interface is used to implement the requirement.
The above is a small part of the jssdk on the iframe page failure solution, I hope to help you!