Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php JS使用两个不同的服务器将父对象重新加载到iframe_Php_Javascript_Iframe - Fatal编程技术网

Php JS使用两个不同的服务器将父对象重新加载到iframe

Php JS使用两个不同的服务器将父对象重新加载到iframe,php,javascript,iframe,Php,Javascript,Iframe,嗨,我有一个项目的问题 我有两台服务器 示例-internal.com example-external.com example internal.com上的页面有一个iframe,用于加载example external.com example internal.com仅保留互联网无法访问的内部信息,仅保留网络 example external.com保存可访问的外部数据 iframe打开一个表单,允许服务器向其发送数据,而不会给我造成问题 当它在iframe中发布数据后,我希望它做的是php

嗨,我有一个项目的问题

我有两台服务器

示例-internal.com example-external.com

example internal.com上的页面有一个iframe,用于加载example external.com

example internal.com仅保留互联网无法访问的内部信息,仅保留网络

example external.com保存可访问的外部数据

iframe打开一个表单,允许服务器向其发送数据,而不会给我造成问题

当它在iframe中发布数据后,我希望它做的是php输出一个脚本来重新加载父对象,但这不起作用。我已经尝试过这种变化,以检查,但没有交易

$auth = mysql_query("INSERT INTO `table` VALUES(........)");
if($auth){echo '
<script type="text/javascript"> 
    self.parent.location.reload();
</script>';
}
$auth=mysql\u查询(“插入到`table`值(……)”;
如果($auth){echo'
self.parent.location.reload();
';
}

请帮助我这么困惑,它曾经工作过,但它在不同的服务器上接缝它不会工作的任何想法,人们如何我可以做到这一点。或者这是因为另一台服务器正在请求重新加载。

您的问题是由于同一源策略造成的,这意味着i-frame不安全,因为它来自不同的域

解决问题的一个可能简单的方法是在页面上设置document.domain,并在iframe“example external.com”中加载

例如:

<script>
    document.domain = "example-internal.com";
</script>

document.domain=“example internal.com”;

我以前遇到过类似的问题。这是一种由浏览器和服务器实施的XSS预防安全措施。这是有办法的。看看postMessage。这只会对你有好处,如果你不需要支持旧的浏览器。另一个更复杂的替代方案是在第一台服务器上使用代理。