简体   繁体   English

如何从其他域添加iframe

[英]how to add iframe from different domain

hi i have the following html document: 您好,我有以下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>

when i upload this document to my web server, the iframe does not loading google , it wants to load iframe source as relative target, not loading google.com.. What i need to do, if i want to load iframe window from different domain? 当我将此文档上传到我的网络服务器时,iframe不会加载google,它希望将iframe源加载为相对目标,而不是加载google.com。。如果我想从其他域加载iframe窗口,我该怎么办?

thanks 谢谢

X-Frame-Options for google.com google.com的 X-Frame-Options

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

it means that you cannot call google.com in an iframe, Google is sending an X-Frame-Options: SAMEORIGIN response header. 这表示您无法在iframe中调用google.com,Google正在发送X-Frame-Options: SAMEORIGIN响应标头。

There are some interesting sources: 有一些有趣的来源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM