簡體   English   中英

無法成功嵌入/顯示 POWR.io 評論

[英]Unable to successfully embed/display POWR.io Reviews

對於遇到這個問題的任何人,希望這對你有幫助。

我創建了一個快速的小 test.html 文件並在 Chrome 中打開它。 它包含以下片段,我無法顯示任何內容。

<div class="powr-reviews" id="2753c372_1606181564"></div>
<script src="https://www.powr.io/powr.js?platform=html"></script>

它應該嵌入/顯示此評論頁面:

https://www.powr.io/reviews/i/26790199#page

任何和所有的幫助將不勝感激。

很難理解https://www.powr.io/powr.js?platform=html

也就是說,這是加載頁面的一種快速但非常原始的方式,但來源必須相同(在這種情況下: https : //powr.io

 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 示例及其復制

 //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 示例及其復制

 <meta http-equiv="refresh" content="0;URL='https://www.powr.io/reviews/i/26790199#page'">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM