4

This example to load a url in an iframe works. However when I change url to something like http://www.yahoo.com the iframe doesn't load antyhing

Here is an example side by side.

In Network tab of developer tools for Chrome, I see that request to Yahoo was cancelled. In FF it doesn't give any errors, just doesn't return any content. IE9 gives a message that It cannot display this content.

enter image description here

This happens in Chrome, FF and IE9 (I haven't tested previous versions of IE).

dev.e.loper
  • 35,446
  • 76
  • 161
  • 247
  • I would recommend that you do no use w3schools for your information (please see http://w3fools.com for exactly why). If you're lucky, the page you're looking at might contains correct information, but there is plenty of information that is quite simply wrong, and any links to the site gives it reputation it doesn't deserve. – freefaller Jul 20 '12 at 14:55
  • Noted. But their example looks same as in w3c docs http://www.w3.org/TR/html4/present/frames.html#h-16.5 – dev.e.loper Jul 20 '12 at 14:58

2 Answers2

4

That is because Yahoo itself prevents this from happening.

It has been noted here: https://stackoverflow.com/a/9013722/476786

To see for yourself, try setting the source to http://www.google.com/ which won't work as well, but then try http://www.bbc.co.uk/ and that will work.

Possibly works as described here: https://stackoverflow.com/a/2896705/476786 using X-FRAME-OPTIONS

Community
  • 1
  • 1
bPratik
  • 6,894
  • 4
  • 36
  • 67
0

If the site hosting the webpage forces the use of a secure HTTPS connection, some browsers (chrome for sure) will require that all network resources use HTTPS as well.

Basically if your site forces HTTPS, try setting src="https://yahoo.com"

This won't solve OP's answer directly due to it being a limitation of Yahoo itself, but other people viewing this page might be experiencing this issue as a result of this (I was).

James Wierzba
  • 16,176
  • 14
  • 79
  • 120