3

I'm trying to load external pages on my website to show a floating div over them with some information about the page, basically like Google images does when you click on an image result.

I'm trying to achieve this by loading the external page in an iframe, however many websites don't seem to like this.

What would be best practice to load external pages on my webpage?

Bunker
  • 1,040
  • 3
  • 12
  • 25

4 Answers4

0

I frames I believe is the standard, can you please give us some examples of sites that do not like being loaded into an iframe? From what I know the website should not even know this.

Mihai P.
  • 9,307
  • 3
  • 38
  • 49
  • For instance: Twitter.com, Facebook.com & Google.com. Also according to this article: http://tech.slashdot.org/story/11/10/23/1949227/google-not-reciprocating-on-iframe-usage – Bunker Dec 07 '12 at 01:44
  • Sites can check this using `if (top.location!= self.location)` – Mark Dec 07 '12 at 01:45
0

Check out colorbox with iframe! It may be what your looking for to show a page in a 'pop-up' like google's image results.

-Enjoy your day!

Michael J. Lee
  • 12,278
  • 3
  • 23
  • 39
0

I think frames are the way to go (in Google Images, a page occasionally breaks out of frame too). There are plugins to help you as mentioned in other answers.

You cannot read external pages with javascript in most browsers, so I think your alternatives are limited to methods involving loading the page from your server, which seems like a lot of trouble. If you insist, I guess you could technically request the page from your server and send either the page of a screengrab to your client...

Mark
  • 18,730
  • 7
  • 107
  • 130
0

You could look at this question: Load external site's content
Anyway, iframe is the standard for this job so I would recommend that, but you can also try:

PHP

$site = "http://stackoverflow.com";
echo $file_get_contents($site);

Ajax

You can use cross-domain Ajax requests as suggested in this question: Load external website into my own website through ajax also see: AJAX cross domain call

JavaScript plugins

ColorBox (as recommended before)
GreyBox

Community
  • 1
  • 1
totymedli
  • 29,531
  • 22
  • 131
  • 165