app中嵌套微信公众号文章链接

        if (article && article.RefferID) {
            $.ajaxPrefilter(function (options) {
                if (options.crossDomain) {
                    let http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
                    options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
                };
            });

            let showSrc = article.SourceUrl;//链接地址
            $.get(showSrc, function (response) {
                let html = response;
                // 确保图片显示
                html = html.replace(/data-src/g, "src").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, '').replace(/https/g, 'http');
                let html_src = 'data:text/html;charset=utf-8,' + html;
                $('#iframe').attr("src", html_src);
            });
        }

 

posted @ 2018-07-27 18:40  小宋宋  阅读(1765)  评论(0编辑  收藏  举报