发布于 2015-04-09 01:57:14 | 233 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Javascript教程,程序狗速度看过来!

JavaScript客户端脚本语言

Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。


1.首先是父页面用window.open打开窗口

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication17.WebForm3" %>

<!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 runat="server">
    <title></title>
    <script type="text/javascript">

        function openChild() {

            var k = window.open(‘WebForm2.aspx?id=110&id1=120&id3=130‘, ‘newwindow‘, ‘height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no‘);
            //window.showModalDialog("/WebForm2.aspx", "obj", "dialogWidth:335px;status:no;dialogHeight:300px");
 
        }

</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
              <input type="text" id="txt10" name="txt10"/>
            <input type="text" id="txt9" name="txt9"/>
                   <input type="text" id="txt11" name="txt11"/>
            <input type="button" id="btn1" name="btn1" value="提交" onclick="openChild()" />
      
    </div>
    </form>
</body>
</html>


2.这是子页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication17.WebForm2" %>

<!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 runat="server">
    <title></title>
    <script type="text/javascript">
        window.onload = function() {

            var k = window.opener;
            document.getElementById("txt1").value = k.document.getElementById("txt10").value;
            var url = location.search;
            if (url.indexOf("id3")!=-1) {
                alert("url id3");
            }
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
              
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
                }
            }
            

        };

    function setFather() {

          //给父窗口空间传值
            var k = window.opener;
            k.document.getElementById("txt10").value =
                document.getElementById("txt1").value;
        }
        //设置返回到父窗口的值
        function  retrunValue() {
            var s =
        document.getElementById("txt2").value;
            window.returnValue = s;
            window.close();
        }
</script>
</head>
<body>
    <form name="abc" runat="server">
          <input type="text" id="txt1" name="txt1"/>
       <input type="text" id="txt2" name="txt2"/>
        <input type="button" id="btn1" name="btn1" value="提交" onclick="setFather()" />
</form>
</body>
</html>

 



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务