-
Notifications
You must be signed in to change notification settings - Fork 39
/
testweixin.html
34 lines (31 loc) · 1.28 KB
/
testweixin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<head>
<!-- <script src="test.js"></script> -->
<script>
function getUrl(URL) {
let http = (window.location.protocol === ‘http:‘ ? ‘http:‘ : ‘https:‘);
let realurl = http + ‘cors-anywhere.herokuapp.com/‘ + URL;
axios.get(realurl).then((response) => {
let html = response.data;
html = html.replace(/data-src/g, "src")
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, ‘‘)
.replace(/https/g, ‘http‘);
let html_src = html;
let iframe = document.getElementById(‘iFrame‘);
iframe.src = html_src;
var doc = iframe.contentDocument || iframe.document;
doc.write(html_src);
doc.getElementById("js_content").style.visibility = "visible";
}, (err) => {
console.log(err);
});
}
//调用getUrl方法,url为微信公众号文章链接
var url = "https://mp.weixin.qq.com/mp/homepage?__biz=Mzg3OTUyMjk3OQ==&hid=1&sn=81e43601cda8700ceaa7ce83ef5bc5d2&scene=18";
getUrl(url);
</script>
</head>
<body>
<iframe id="iFrame" width="100%"></iframe>
</body>
</html>