Javascript window.location阻止iframe重定向父窗口

Javascript window.location阻止iframe重定向父窗口,javascript,html,iframe,Javascript,Html,Iframe,因此,我尝试了许多方法来自动重定向加载到某个页面上的iframe中的内容,它们似乎总是触发父窗口重新加载/重定向,而不是将iframe定向到其所需的位置 我知道大多数人希望相反,当他们在iframe中完成时,他们希望重新加载父窗口或将其定向到其他地方。但在这种情况下,我希望我的脚本继续到另一页 是否有一种内置机制不允许iframe在其内部重定向 为了方便起见,让我们假设代码是 if(someAction === true) { window.location = '/some/new/pa

因此,我尝试了许多方法来自动重定向加载到某个页面上的iframe中的内容,它们似乎总是触发父窗口重新加载/重定向,而不是将iframe定向到其所需的位置

我知道大多数人希望相反,当他们在iframe中完成时,他们希望重新加载父窗口或将其定向到其他地方。但在这种情况下,我希望我的脚本继续到另一页

是否有一种内置机制不允许iframe在其内部重定向

为了方便起见,让我们假设代码是

if(someAction === true) {
   window.location = '/some/new/path/index_new.html?param=something';
}
我也用
window.top.location
window.parent.location
尝试过这个方法,我想还有一些其他的随机变量。包括在每个变量的末尾追加
.href
。在out fail的情况下,iframe的父窗口似乎总是重定向,而不是希望的实际iframe本身

iframe是一个简单的iframe


用于重定向iframe的脚本嵌入在/original/path/index.html中。请发布您的代码或代码片段,以便我们了解您正在使用的是什么。我为一个站点使用了一个Iframe,该站点在同一个框架内从父页面打开了三个不同的页面,并使用cookies来来回传递数据。但是,请显示一些html div和/或js,以便我们可以看到您希望它如何工作。下面是我工作的一些代码。我使用本地存储

    function Redirect($page) {
      localStorage.setItem('page',$page);
            window.location="validateorder.htm";

           }

    function orderValidate($page) {
      localStorage.setItem('page',$page);
      $arr = $('iframe').contents().find('form').serializeArray();

      $.each($arr,function(i,v){
            createCookie(i,v);
      });


      window.location="ordersummary.htm";
    }

$(document).ready(function(){
    $('iframe').load(function() {
        $page = localStorage.getItem('page');
        $subtotal = localStorage.getItem('subtotal');
        $tax = localStorage.getItem('tax');
        $total = localStorage.getItem('total');
        $table = $('iframe').contents().find('td#optionsPrice');

        $form = $('iframe').contents().find('#frmContact');
        $theform = $('iframe').contents().find('#theform');

        if($table.length > 0){
            $('iframe').contents().find('td#optionsPrice').text($subtotal);
            $('iframe').contents().find('td#tax').text($tax);
            $('iframe').contents().find('td#totalPrice').text($total);
        }

        if($form.length > 0){
            $form.find('input').each(function(){
                $name = $(this).attr('name');
                $type = $(this).attr('type');
                if($type != 'button'){
                    $(this).val(readCookie($name));
                }
            });
        }

另一件值得一提的事情是,我可以在我的
/original/path/index.html
的嵌入式源代码中实际单击一个链接,该链接在iframe中指示良好。就在我试图让它自动重定向的时候,我似乎遇到了一些问题。意外地