我无法加载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>
答案 0 :(得分:1)
这是因为facebook限制在其他域框架中托管页面。
通过附加X-Frame-Options
标题来完成。 X-frame-options