iframe:重定向到外部网址

时间:2015-09-30 10:42:14

标签: javascript php redirect iframe yii

我正在Yii的网站上工作。情况就是这样。在网站中,users提供了一段代码,如下所示:

<iframe height="700" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src="http://djoneclick.com/index.php?r=webservice/form&id=6b720ff1c3cdce6c278e784a3228fd9fadc6d864" title="" >
<a href="/index.php?r=webservice/form&id=6b720ff1c3cdce6c278e784a3228fd9fadc6d864" title="">

</a>
</iframe>

User可以将其嵌入到他们想要的任何地方,并从所需的受众群体中进行查询。此iframe包含src formcontroller提交Yii中的controller。在if中,在具有特定true条件redirects时,它url到外部url。它会重定向,但iframe(重定向到的内容)的内容会显示在redirect中。我想要的是实际urlR&D。  我花了几个小时*为此但找不到任何解决方案。有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

$("#idForm").submit(function() {

var url = "path/to/your/script.php"; // the script where you handle the form input.

$.ajax({
       type: "POST",
       url: url,
       data: $("#idForm").serialize(), // serializes the form's elements.
       success: function(data)
       {
           window.top.location.href = "http://www.yoursite.com";
       }
     });

      return false; // avoid to execute the actual submit of the form.
});

答案 1 :(得分:1)

controller

中条件为真后尝试此操作
echo "<script>";
echo "this.parent.location.href = '$externel_url'";
echo "</script>";