i tried it several times and different ways. I want to check if the first value of an if statement is an iframe. Can anyone explain to me what im doing wrong here? im really confused. I need to check if the value is an iframe or not so i can use some css to hide the div if the value isn't i tried several different variations but i hadn't find the right Syntax to check if im right. Currently the value is always an iframe but the next step would be integrate or deliver 1x1 pixel. Thats why i had to check it
const containerToProof = useRef()
useEffect(()=>{
// console.log('saysomething',containerToProof.current.firstElementChild.innerHTML)
var isiframe = containerToProof.current.firstElementChild.innerHTML;
console.log('isiframe', isiframe);
if(isiframe.tagName=== iframe){
console.log('allo')
setAdSpotvisible(true)
}else{
setAdSpotvisible(false)
}
},[<iframe/>]);
/*
if(containerToProof.current=='iframe'){
console.log('allo')
}*/
return (
<div>
<div ref={containerToProof} ></div>
);`````
You can use regex for the check, atleast it worked in my case.
You can do the following:
Here is a working example: