1 回答

TA贡献2041条经验 获得超4个赞
var theFrame=document.createElement('iframe')
theFrame.src="https://www.powr.io/reviews/i/26790199#page"
document.body.appendChild(theFrame)
//document.appendChild isn't reliable since it says some ONLY ALLOWS ONE APPENDAGE or something like that
//the above code only works if cors doesn't block you, meaning that your source for this would be from powr.io as well(THIS IS A SANDBOX SO IT GETS BLOCKED BECAUSE OF ORIGIN DIFFERENCE)
//if i run the code below, it works on newtab(if u pop up the console paste and enter)
document.write('<div class="powr-reviews" id="2753c372_1606181564"></div>')
var x=document.createElement('script')
x.src="https://www.powr.io/powr.js?platform=html"
document.body.appendChild(x)
现在我有一个小的repl来表明你的 2 行工作,但如果你的源(在客户端运行它时的原点)是文件,它就不起作用
现在在下面,我尝试模仿代码到底做了什么
JavaScript 示例及其repl
//iframe loader
function iframer(sourceUrl){
document.body.innerHTML="" //makes sure ONLY this loads
var iframe = document.createElement('iframe');
iframe.src = sourceUrl;
iframe.width=screen.availWidth;
iframe.height=screen.availHeight;
iframe.style="border: solid transparent";
document.body.appendChild(iframe);
return iframe;
}
var myFrame=iframer("https://www.powr.io/reviews/i/26790199#page")
console.log(myFrame)
HTML 示例及其repl
<meta http-equiv="refresh" content="0;URL='https://www.powr.io/reviews/i/26790199#page'">
添加回答
举报