php - Why Iframe dosen't work for yahoo.com -


i find doesn't work:

<iframe src="http://www.yahoo.com"> </iframe> 

i have read question, don't understand mean add:

<?php header('x-frame-options: goforit');  ?> 

i tried add top of html file(change php file, of course), , php file became:

<?php header('x-frame-options: goforit');  ?> <iframe src="http://www.yahoo.com"> </iframe> 

i run in appserv(with php 5.2.6), , doesn't work. explain should overcome this?

you're out of luck: yahoo.com doesn't allow embed site in iframe. nor facebook or other popular sites.

the reason restriction clickjacking.

you can verify checking response headers site; specify x-frame-options:sameorigin means yahoo.com can embed yahoo.com pages.

some older browsers won't enforce header new ones will. afaik, there's no simple way around it.

the solution can think of implementing proxy script, i.e. embed script lives on server fetches remote content you.

eg. iframe calls "/my-proxy.php?url=http://www.yahoo.com/" , script like:

<?php  header('x-frame-options: sameorigin'); // don't allow other sites use proxy echo file_get_contents($_get['url']); 

your mileage may vary...


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -