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);
            });
        }

猜你喜欢

转载自www.cnblogs.com/sjw-dmwz/p/9379194.html