xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

hashChange & url change & QRCode & canvas to image

hashChange & url change & QRCode & canvas to image


"use strict";

/**
 *
 * @author xgqfrms
 * @license MIT
 * @copyright xgqfrms
 *
 * @description iframe for eapp tesing
 * @augments
 * @example
 *
 */

const iframeForEapp = (debug = false) => {
    let iframe = document.querySelector(`[data-dom="iframe"]`);
    let hash_url = window.parent.location.hash.slice(1);
    if (iframe && hash_url) {
        iframe.src = `http://${hash_url}`;
    } else {
        if (debug) {
            console.log(`hash_url =`, hash_url);
        }
    }
};

let iframe = document.querySelector(`[data-dom="iframe"]`);
if (iframe) {
    let url = window.parent.location.search.slice(1);
    console.log(`url =`, url);
    // iframe.src = `http://${url}`;
    let hash_url = window.parent.location.hash.slice(1);
    console.log(`hash_url =`, hash_url);
    iframe.src = `http://${hash_url}`;
}
// hashChange ??? url change


hashChange

https://www.cnblogs.com/xgqfrms/p/9301751.html


SVG to Image

SVG to Image in js

https://www.cnblogs.com/xgqfrms/p/10516810.html

https://www.cnblogs.com/xgqfrms/p/10518203.html


canvas.toDataURL();

https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLCanvasElement/toDataURL


<canvas id="canvas" width="5" height="5"></canvas>
<no-script>可以用这样的方式获取一个 data-URL</no-script>

let  canvas = document.getElementById("canvas");
let dataURL = canvas.toDataURL();

console.log(dataURL);
// "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNby... blAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC"

// 设置 jpeg 图片的质量节
let fullQuality = canvas.toDataURL("image/jpeg", 1.0);
// data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...9oADAMBAAIRAxEAPwD/AD/6AP/Z"

let mediumQuality = canvas.toDataURL("image/jpeg", 0.5);

let lowQuality = canvas.toDataURL("image/jpeg", 0.1);


iframe & HTTPS & CORS

https://iframe.xgqfrms.xyz/eapp/index.html#blog.sina.cn

HTTPS & Android

OK

HTTP & Android

OK

http://10.1.12.131/eapp-iframe/index.html#blog.sina.cn

HTTP & iOS

error

https://iframe.xgqfrms.xyz/eapp/index.html#blog.sina.cn



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2019-04-22 11:18  xgqfrms  阅读(283)  评论(4编辑  收藏  举报