简体   繁体   English

iframe:重定向到外部网址

[英]iframe: Redirect to externel url

I am working on a website in Yii . 我正在Yii网站上工作。 The situation is like this. 情况就是这样。 In the website, the users are provided a piece of code that is like this: 在网站上,为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 can embed this anywhere they want and take inquiries from the desired audience. User可以将其嵌入所需的任何位置,并向所需的受众询问。 This iframe includes the src which is a form that submits to a controller in Yii . iframe包含src ,这是一种向Yiicontroller提交的form In the controller , upon having a specif if condition true , it redirects to the externel url . controllerif条件为true ,则将其redirects到外部url It redirects but the contents of the url (to which it is redirected) are displayed in the iframe . 它重定向,但是url的内容(重定向到该url )显示在iframe What I want is to actually redirect to that url . 我想要的实际上是redirect到该url I have spent hours upon R&D for this but could not find any solution. 为此,我花了几个小时进行R&D ,但找不到任何解决方案。 any help? 有什么帮助吗?

$("#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.
});

Try this after the condition is true in your controller : controller的条件为真之后尝试以下操作:

echo "<script>";
echo "this.parent.location.href = '$externel_url'";
echo "</script>";

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

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