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'">
添加回答
舉報