我有一个弹出窗口(我必须使用它),它是在链接点击时打开的。我让用户浏览一系列选择属性的页面,然后发送到购物车。在达到特定页面后弹出浏览器返回到父浏览器
我的问题:在用户到达选择过程结束后,我想杀死打开的弹出窗口并将请求发送回原始浏览器(父),以便用户可以结帐。
任何想法我会怎么做?
我有一个弹出窗口(我必须使用它),它是在链接点击时打开的。我让用户浏览一系列选择属性的页面,然后发送到购物车。在达到特定页面后弹出浏览器返回到父浏览器
我的问题:在用户到达选择过程结束后,我想杀死打开的弹出窗口并将请求发送回原始浏览器(父),以便用户可以结帐。
任何想法我会怎么做?
Javascript:在儿童(弹出)窗口中。
window.opener.location = 'page.html";
window.close();
这是你在找什么?
可以使用JavaScript中的“opener”访问父窗口。 例子:
window.opener.title='hello parent window';
或
window.opener.location.href='http://redirect.address';
脚本在我的孩子形式:
<script language="JavaScript" type="text/javascript">
function SetData() {
// form validation
// var frmvalidator = new Validator("myForm");
// frmvalidator.addValidation("name","req","Please enter Account Name");
// get the new dialog values
var str1 = document.getElementById("name").value;
var winArgs = str1;
// pass the values back as arguments
window.returnValue = winArgs;
window.close();
document.myForm.submit();
}
</script>
在我父窗体
脚本:
<% @account_head= current_company.account_heads.find_by_name("Sundry Debtors")%>
<script type="text/javascript">
function OpenDialog() {
var winSettings = 'center:yes;resizable:no;help:yes;status:no;dialogWidth:450px;dialogHeight:200px';
// return the dialog control values after passing them as a parameter
winArgs = window.showModalDialog('<%= "/accounts/new?account_head_id=#{@account_head.id} #man" %>', winSettings);
if(winArgs == null) {
window.alert("no data returned!");
} else {
// set the values from what's returned
document.getElementById("to_account_auto_complete").value = winArgs;
}
}
</script>
这是工作,但不作为我想,任何一个如果发现克请提出解决方案。
你们真棒 – MedicineMan 2010-01-27 22:15:44