我无法加载 iframe 内的所有网站,例如 youtube、facebook 和 twitter。 我从数据库加载所有页面,其他网站加载正常。
我尝试过:
js:
function showeffect(sUrl,sName)
{
$('#effect').hide(1000);
$('#effect').show(2200);
$('#website').attr("src", sUrl);
}
php:
<?php
$sql = "SELECT naam, url FROM items";
$database = new PDO('mysql:host=localhost;dbname=startandhome','root','');
$results = $database->query($sql);
$contentregel = 'contentregelblauw';
foreach($results as $row)
{
$itemnaam = $row['naam'];
$itemUrl = $row['url'];
echo "<div class=\"" .$contentregel ."\"><a href=\"#\" onclick=\"showeffect('".$itemUrl ."','".$itemnaam ."'); return false;\">" .$itemnaam ."</a></div>";
if ($contentregel == 'contentregelgrijs')
{
$contentregel = 'contentregelblauw';
}
else
{
$contentregel = 'contentregelgrijs';
}
}
?>
html:
<iframe id="website" class="website" src=""></iframe>
最佳答案
这是因为 facebook 限制在其他域框架中托管该页面。 通常通过附加 X-Frame-Options header 来完成。 X-frame-options
- Facebook 和 Twitter 网站有 x-frame-options,这意味着它们不允许跨源调用。他们通过 x-frame-options 进行限制。
关于php - 无法加载所有 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14599475/