If I have different iframes
on a page and want to load the same url
in each one of them, if I simply use the same url
I can see in Developer Tools that there're as many http requests as iframes
How could I prevent this to happen, and to do only one request and that this populates all iframes?
Should I load one iframe and then clone it? This first attempt is not working
(React)
const [url, setUrl] = useState()
useEffect(() => {
const request = new Request('anyurl')
setUrl(request.url)
}, [])
return (
{Object.entries(iframeArray).map(() => (
<Iframe sandbox="" src={url} />
))}
)
Unfortunately, this doesn´t work, since each <iframe>
acts on its own.
Other question: Why do you want to reuse them? If you want to load static data which can be reused, please use an ajax request to load data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.