为了账号安全,请及时绑定邮箱和手机立即绑定

无法成功嵌入/显示 POWR.io 评论

无法成功嵌入/显示 POWR.io 评论

Cats萌萌 2023-06-15 10:30:28
对于遇到这个问题的任何人,希望这能找到你。我创建了一个快速的小 test.html 文件并在 Chrome 中打开它。它包括以下片段,我无法显示任何内容。<div class="powr-reviews" id="2753c372_1606181564"></div> <script src="https://www.powr.io/powr.js?platform=html"></script>任何和所有帮助将不胜感激。
查看完整描述

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'">


查看完整回答
反对 回复 2023-06-15
  • 1 回答
  • 0 关注
  • 146 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号