<script language=javascript> function outPut() {
var text = document.abc.text.value;
var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
win.document.writeln("<title>output</title>");
win.document.writeln("Your information is: <p>");
win.document.writeln(text);
win.document.close();
win.focus();
}
</script><form name="abc" method="post"> <input type="text" name="text" size='50'>
<input type="button" value='submit' onClick="outPut()">
</form>
上面这段代码是window.open版本的,我想把它改成window.showModalDialog版本的
难点在于:
window.open方法会返回一个新打开窗口的引用win,然后就可以把信息传给这个win
但是window.showModalDialog方法就不会自动返回新打开的dialog的引用,
那么,我如何去获得这个引用呢?
var text = document.abc.text.value;
var win = window.open("","mywin", "menubar=no,width=400,height=100,resizeable=yes");
win.document.writeln("<title>output</title>");
win.document.writeln("Your information is: <p>");
win.document.writeln(text);
win.document.close();
win.focus();
}
</script><form name="abc" method="post"> <input type="text" name="text" size='50'>
<input type="button" value='submit' onClick="outPut()">
</form>
上面这段代码是window.open版本的,我想把它改成window.showModalDialog版本的
难点在于:
window.open方法会返回一个新打开窗口的引用win,然后就可以把信息传给这个win
但是window.showModalDialog方法就不会自动返回新打开的dialog的引用,
那么,我如何去获得这个引用呢?
http://download.csdn.net/source/308916DHTML参考手册.rar
http://download.csdn.net/source/308913样式表中文手册.chm
http://download.csdn.net/source/304124
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.html",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.html 代码如下:<script>
var obj = window.dialogArguments
document.write("您传递的参数为:" + obj.name)
</script>
<html>
<head>
<script language=javascript> function outPut() {
var text = document.abc.text.value;
window.showModalDialog("child.html",text,"dialogWidth=200px,dialogHeight=10px");
}
</script>
</head>
<body>
<form name="abc" method="post">
<input type="text" name="text" size='50'>
<input type="button" value='submit' onClick="outPut()">
</form>
</body>
</html>
child.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript">
window.onload=function()
{
var text = window.dialogArguments;
document.write("the information is:");
document.write("<br/>");
document.write(text);
}
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
在子页面通过window.dialogArguments来得到传递的参数
有没有办法能实现像对话框这样的效果:弹出一个子窗口,父窗口就不能再被激活了,除非这个子窗口被关闭
var text = document.abc.text.value;
var win = window.showModelessDialog("second.html",window);
win.document.writeln("<title>output</title>");
win.document.writeln("Your information is: <p>");
win.document.writeln(text);
win.document.close();
win.focus();
}
</script><form name="abc" method="post"> <input type="text" name="text" size='50'>
<input type="button" value='submit' onClick="outPut()">
</form>//////////////////////////////////////////////////////////////
在second.html中
<script language=javascript> function getobj() {
var getObj=dialogArguments;
//这里的getObj对象即相当于第一个窗口的window;在进行其他传值操作;
}
getobj()
</script>
第一个html中写 <script language=javascript> function outPut() {
var text = document.abc.text.value;
window.showModelessDialog("second.html",window);
}
</script> <form name="abc" method="post"> <input type="text" name="text" size='50'>
<input type="button" value='submit' onClick="outPut()">
</form> //////////////////////////////////////////////////////////////
在second.html中
<script language=javascript> function getobj() {
var getObj=dialogArguments;
//这里的getObj对象即相当于第一个窗口的window;在进行其他传值操作;
var text2=getObj.document.abc.text.value;
}
getobj()
</script>