0

I have seen all the posts in the forum, but I did not find an answer, the posts are very old. I need to load an external webpage in a div of another website. In my local site I have this script:

<script type="text/javascript">
$(document).ready(function() {
    $('#content').load('divelencoarticoli.html');
});
</script>

in the body

<div style="width: 100%" id="content">Initial content in test.html</div>

but the external webpage does not load.

The page for external load is on another site of my server (its my another website) and there is no problem of safety. Thanks in advance.

niko
  • 9,285
  • 27
  • 84
  • 131

2 Answers2

1

You can use an iframe like this :

<iframe src="divelencoarticoli.html"></iframe>
Corentin
  • 149
  • 9
1

Basically not possible with most of the websites and with most of the browsers. The main issue is security due to cross site scripting. You may refer the following in this respect.

Taken from this Answer:

Google uses an X-FRAME-OPTIONS HTTP header to disallow putting their pages in iframes: https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header

Almost all modern browsers will refuse to put pages with this HTTP header in an iframe. There's nothing you can do about that.

Another reference (Security risks for using an iframe for external website?):

The main problem would be if you didn't want the iframe to interact with the parent or if you did. Attempts by javascript to do so are blocked by some browsers to prevent cross site scripting hacks. Not all browsers will stop it though. So just be aware that in some browsers javascript from the frame could interact with your parent page - which might be a problem if you had something sensitive on there. The flip side being if you need the frame to interact with the parent it won't work in some browsers.

Read these in this respect:

  1. X-Frame-Options
  2. ClickJacking Defense
Community
  • 1
  • 1
Rajesh Paul
  • 6,793
  • 6
  • 40
  • 57