如何从不同的域添加iframe

时间:2016-10-10 17:23:56

标签: html iframe dns src

您好我有以下HTML文档:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>mytitle</title>
<style>
#idiv {
    position: fixed;
    top:1px;
    height:100px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    background:#0C0;
}
#iframe_main {
    position:fixed;
    top:100px;
    height: 100%;
    width: 100%;
}


</style>

<style>
.myButton {
    -moz-box-shadow:inset 0px 0px 27px 7px #fff6af;
    -webkit-box-shadow:inset 0px 0px 27px 7px #fff6af;
    box-shadow:inset 0px 0px 27px 7px #fff6af;
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffec64), color-stop(1, #ffab23));
    background:-moz-linear-gradient(top, #ffec64 5%, #ffab23 100%);
    background:-webkit-linear-gradient(top, #ffec64 5%, #ffab23 100%);
    background:-o-linear-gradient(top, #ffec64 5%, #ffab23 100%);
    background:-ms-linear-gradient(top, #ffec64 5%, #ffab23 100%);
    background:linear-gradient(to bottom, #ffec64 5%, #ffab23 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64', endColorstr='#ffab23',GradientType=0);
    background-color:#ffec64;
    -moz-border-radius:27px;
    -webkit-border-radius:27px;
    border-radius:27px;
    border:1px solid #ffaa22;
    display:inline-block;
    cursor:pointer;
    color:#333333;
    font-size:18px;
    font-weight:bold;
    padding:8px 10px;
    text-decoration:none;
    text-shadow:-12px 12px 11px #ffee66;
}
.myButton:hover {
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffab23), color-stop(1, #ffec64));
    background:-moz-linear-gradient(top, #ffab23 5%, #ffec64 100%);
    background:-webkit-linear-gradient(top, #ffab23 5%, #ffec64 100%);
    background:-o-linear-gradient(top, #ffab23 5%, #ffec64 100%);
    background:-ms-linear-gradient(top, #ffab23 5%, #ffec64 100%);
    background:linear-gradient(to bottom, #ffab23 5%, #ffec64 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffab23', endColorstr='#ffec64',GradientType=0);
    background-color:#ffab23;
}


</style>

</head>
<body>
<div id="idiv">
<input class="myButton" style="left: 10px; width:auto; height:auto; visibility: visible;z-index: -0; width: auto" value="RELOAD PAGE" onclick="window.location.reload()"/>
</div>
<div style="top:100px;height: auto; width:auto;">

<?php
echo "<iframe id= \"iframe_main\" src=\"http://google.com/\"></iframe>";
?>  

</div>


</body>
</html>

当我将此文档上传到我的网络服务器时,iframe没有加载谷歌,它想加载iframe源作为相对目标,而不是加载google.com ..我需要做什么,如果我想加载iframe窗口来自不同的领域?

感谢

1 个答案:

答案 0 :(得分:0)

google.com

的X-Frame选项
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW-FROM https://google.com/

这意味着您无法在iframe中调用google.com,Google正在发送X-Frame-Options: SAMEORIGIN响应标头。

有一些有趣的消息来源:

相关问题