求助:js或者jquery。关闭当前子页面并且父页面跳转
展开全部
如果是模态窗口弹出
<form name="form1">
<input type="text" name="fag1">
<input type="text" name="fag2">
</form>
function shw(){
var url="open.html";
//----------方法一--start-------
var obj=document.form1; //指定页面对象
var returnValue=window.showModalDialog(url ,obj,'dialogHeight:550px;dialogWidth:500px;center:yes'); //方法返回值
//----------方法一--end-------
alert(returnValue);
}
如果是非模态窗口弹出,那么
<script type="text/javascript">
//弹出窗口
function openwin(url,width,height){
var l=window.screen.width ;
var w= window.screen.height;
var al=(l-width)/2;
var aw=(w-height)/2;
var OpenWindow=window.open(url,"弹出窗口","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height+",top="+aw+",left="+al+"");
OpenWindow.focus();
if(OpenWindow!=null){ //弹出窗口关闭事件
//if(window.attachEvent) OpenWindow.attachEvent("onbeforeunload", quickOut);
if(window.attachEvent) OpenWindow.attachEvent("onunload", quickOut);
}
}
//关闭触发方法
function quickOut()
{
alert("窗口已关闭");
}
</script>
<input type="button" value="ok" onclick="openwin('open.html','600','500')">
<input type="text" name="txt0" id="txt0"> 注意:firefox这里一定要写ID属性,不然取不到值
<form name="form1">
<input type="text" name="fag1">
<input type="text" name="fag2">
</form>
function shw(){
var url="open.html";
//----------方法一--start-------
var obj=document.form1; //指定页面对象
var returnValue=window.showModalDialog(url ,obj,'dialogHeight:550px;dialogWidth:500px;center:yes'); //方法返回值
//----------方法一--end-------
alert(returnValue);
}
如果是非模态窗口弹出,那么
<script type="text/javascript">
//弹出窗口
function openwin(url,width,height){
var l=window.screen.width ;
var w= window.screen.height;
var al=(l-width)/2;
var aw=(w-height)/2;
var OpenWindow=window.open(url,"弹出窗口","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height+",top="+aw+",left="+al+"");
OpenWindow.focus();
if(OpenWindow!=null){ //弹出窗口关闭事件
//if(window.attachEvent) OpenWindow.attachEvent("onbeforeunload", quickOut);
if(window.attachEvent) OpenWindow.attachEvent("onunload", quickOut);
}
}
//关闭触发方法
function quickOut()
{
alert("窗口已关闭");
}
</script>
<input type="button" value="ok" onclick="openwin('open.html','600','500')">
<input type="text" name="txt0" id="txt0"> 注意:firefox这里一定要写ID属性,不然取不到值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询