Displaying another website in an iframe
If a simple <iframe>
isn't working then there isn't any way of doing it in Javascript either. The most likely reason for the iframe not working is because the target site is sending a header to prevent other sites iframing it:
X-Frame-Options: DENY
A lot of sites will do this to prevent a common vulnerability known as UI Redressing or Clickjacking. Some sites will also include some frame busting Javascript as a backup security measure to the HTTP header.
From MDN:
The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a
<frame>
or<iframe>
. Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.
SmartDev
By Day : Laravel 5.2 By Night : Angular JS 2 For Fun : Play with My 19 Months OLD son. "I Will try to answer your questions if you ask during DAY or NIGHT."
Updated on June 04, 2022Comments
-
SmartDev almost 2 years
When I use an iframe it is not displaying. Does anyone know an alternative way to display other website on my webpage, using either iframe or div. (Or simple JavaScript, that would be really great.)
I have tried an iframe: Doesn't work
I tried
location.reference
: Doesn't work.Any ideas?