这个是页首

关于浏览器上弹出窗口的探索

以前很多系统选择代码使用的是点一个按钮,弹出一个窗口,选择以后,填写好窗口上选择的内容,记得HZ2004是用windows.open实现的,查询了一下发现widnows.open应该没办法实现modal的模式,后来发现还有一个函数:window.showModalDialog

http://wenku.baidu.com/view/5e9fb010a2161479171128a6.html

3

例子:

问题一:我想弹出一个窗口,然后在弹出的窗口里,选择或输入一些信息,

要求这些信息返

回到父页面。

建立父页面:

a.htm

CODE: 

<html>

<head> 

    <title></title> 

    <mce:script language="javascript" type="text/javascript"><!--

        function OpenWin(){ 

            var getv = showModalDialog("b.htm", "", "dialogWidth:320px;

dialogHeight:200px;status:no;help:yes");

            if (getv != null){ 

                document.forms[0].txtName.value=getv.split(",")[0];

                document.forms[0].txtAge.value=getv.split(",")[1];

            }

        } 

// --></mce:script>

</head>

<body> 

    <form id="form1" runat="server" method="post">

    <input type="text" name="txtName" id="txtName" /> 

    <input type="text" name="txtAge" id="txtAge" /> 

    <input type="button" name="Submit" value="

打开

" onclick="OpenWin()" />

    </form>

</body> 

</html>

建立子页面:

b.htm

CODE: 

<html>

<head> 

    <title></title> 

    <mce:script language="javascript" type="text/javascript"><!--

        function GetValue(){ 

            //window.returnValue

存放子窗口向父窗口所传值的内容

        window.returnValue=document.forms[0].txtName.value+","+document.forms

[0].txtAge.value; 

            window.close();

        }// --></mce:script>

</head>

<body> 

    <form id="form1" runat="server" method="post">

    <br /> 

姓名:

<input name="txtName" type="text" id="txtName" /><br />

年龄:

<input name="txtAge" type="text" id="txtAge" /> 

    <input type="button" name="Submit" value="

关闭

" onclick="GetValue()" />

    </form>

</body> 

</html>

这里利用了模式窗口

window.showModalDialog(),

利用

window.returnValue 

= window.showModalDialog(sURL [, vArguments] [, sFeatures])

,我们可以打开

一个模态窗口,

该窗口的优点是限制用户只能对当前的页面进行操作,

而对其父页面不能进

行操作,常用于向导或者信息获取页面。利用其中的

vArguments

我们可以在父页面和弹

出的页面中进行参数的传递,

参数可以为自定义的对象,

也可以传递父页面中任何一个控件

的引用,

这使得我们可以很容易的来操作父页面中的各个元素,

使得参数的传递变得非常容

易。

 

**************************

注释:

父亲通过子窗口的window.returnValue得到返回的结果。

------------------------------------------

对于firefox不支持showModalDialog。

----------------------------------------------

js访问iframe内的js变量

只能使用如下格式:

document.frames["iframe的name"].变量名

如果使用document.getElementById(“iframe的name”)..变量名,在使用时会报undefined

http://blog.csdn.net/hillpool/article/details/7052622

 

另外:定义iframe的时候必须把id和name都定义上

http://blog.csdn.net/zhengmingli/article/details/5656025

原本页面中有一 iframe:

<iframe id="ifControl"  style="width: 100%;" frameborder="0" height="700px" scrolling="no"></iframe>

通过js赋src的值:window.frames["ifControl"].location.href=“”;

这样写IE下是正常的,但在火狐下不显示。。

解决办法:    

<iframe id="ifControl" name="ifControl" style="width: 100%;" frameborder="0" height="700px" scrolling="no"></iframe>把iframe的id,name都赋值。。

另外:<script>parent.window.location="url"</script>在IE和火狐下通用。

<script>parent.window.location.href("url")</script>在火狐下无效。。

posted @ 2013-05-29 16:09  网际浪人1  阅读(216)  评论(0编辑  收藏  举报
这个是页脚