<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function Send() {
alert("开始进行提交操作")
}
function Close() {
window.close();
alert("提交完关闭当前窗口") }
</script>
</head>
<body>
<form target="_blank" action="http://www.csdn.net" onsubmit="Send();Close();">
<input type="submit" value="提交" />
</form>
</body>
</html>如上面代码,因为我现在要做一个支付页面,而我的页面是在iframe里面的,
如果在iframe里面进行post到alipay的话,会出错,所以这时post就得加上 target="_blank"
但加上_blank的时候就是在新窗口,但当前客户下单的页面就没有半闭
如上我的写法是错误的,那正确的写法应该是怎么样谢谢
<form target="_top" action="http://www.csdn.net">
<input type="submit" value="提交" />
</form>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>text</title>
<script>
function checkLeave(){
alert("提交完关闭当前窗口");
}
</script>
</head>
<body onunload="checkLeave()">
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function Send() {
alert("开始进行提交操作")
window.close();
}
function Close() { }
</script>
</head>
<body>
<form target="_blank" action="http://www.csdn.net" onsubmit="Send()">
<input type="submit" value="提交" />
</form>
</body>
</html>
代码在Firefox中不通过,没有关闭窗口
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
function Send() {
alert("开始进行提交操作")
}
function Close() {
window.close();
} function doSubmit(fn){
var frm = document.getElementById("frm");
frm.submit();
fn();
}
</script>
</head>
<body onload="init()">
<form id="frm" target="_blank" action="http://www.csdn.net">
<input type="button" value="提交" onclick="doSubmit(Close)"/>
</form>
</body></html>
找到dom.allow_scripts_to_close_windows这项并改为true。