I have a problem with getting the contents of website X from website Y I have localhost:3000 and http://levshapiro.com
I watched a video how to do it and wrote this:
// localhost:3000 ( P.S. built on React )
function App() {
let url = "http://levshapiro.com";
useEffect(() => {
let iframe = document.getElementById("iframe");
iframe.contentWindow.postMessage("HEJ", "*");
}, [])
return (
<>
<div className="console">
<span id="website_url">Website: {url}</span>
</div>
<iframe src={url} id="iframe" title="something"/>
</>
)
}
// http://levshapiro.com
window.addEventListener("message", function(message) {
alert(message.data)
})
// + In HTML "<h1>Hello World!</h1>"
In this video ( https://www.youtube.com/watch?v=i9nFBZ-MiuQ ) it worked, but for me it didn't. Could someone tell me why?