2011-03-11 42 views
0

所以,这里发生的事情。我点击提交按钮它去some.php和获取与item2的JSON值,我们打开print.php一个新窗口。之后,生成print.php的页面将被一个函数刷新。现在我的问题,我想保留在顶部的print.php窗口,并刷新产生它的后窗。所以我去了并使用window.location = self.location();。现在我的print.php保持在顶部,但需要刷新的页面给了我错误"object doesnot support this action"我如何把窗口放在顶部,并在JavaScript中刷新后窗

$("#submit-button").click(function(){ 
    $.post("some.php?id="+id1value,function(data){ 
      if(data.item2 !=null){ 
      window.open('print.php?id1='+id1value+'&id2='+ data.item2); 
       refreshBack($("#div1").text()); 
      }else{ 
       //Do Process for else 
      } },'json') 

    }   
) 
}); 

function refreshBack(text){ 
if(text==="abc"){ 
url = "one.php"; 
} 
else{ 
url = 'two.php?id3='+id3value; 
} 
document.form_name.action=url; 
document.form_name.submit(); 

} 

回答

1

刷新会推出一个弹出窗口,使用拥有窗口:

window.opener.location.reload(); 

要刷新子窗口,节省window.open的提法(),过一会儿给参考的位置重装。

var myPopup = window.open('print.php?id1='+id1value+'&id2='+ data.item2); 

... 

myPopup.location.reload(); 

要赋予特定窗口前景焦点,请在任一窗口对象中使用.focus()方法。

// Focus the current window 
window.focus(); 

// Focus the child window 
myPopup.focus(); 

// Focus the window that opened the current popup 
window.opener.focus();