zoukankan      html  css  js  c++  java
  • js串讲整理

    js子级窗口向父级窗口传值

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="javascript">
    var a = window.open("b.php","_blank","width=200 height=200 toolbar=no");  //在新窗口打开b.php
    
    //window.setTimeout("ccc()",3000);
    
    function ccc()
    {
        a.close();
    }
    </script>
    </head>
    
    <body>
    <div id="dd"></div>
    </body>
    </html>
    View Code
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="javascript">
    function dodo()
    {
        //取出值
        var s = document.getElementById("t1").value;
        
        //给父窗口
        var dd = window.opener.document.getElementById("dd");  //opener打开父级窗口
        dd.innerHTML = s;
    }
    </script>
    </head>
    
    <body>
    <form>
    <input type="text" id="t1" name="t1">
    <input type="button" value="点击给父窗口" onclick="dodo()">
    </form>
    </body>
    </html>
    View Code

    js一次打开或关闭多个窗口

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script language="javascript">
    
    var arr = new Array();
    function doopen()
    {
        for(var i=1;i<=5;i++)
        {
            arr[i-1] = window.open("b.php","_blank","width=200 height=100 toolbar=no");
        }
    }
    function doclose()
    {
        for(var i=0;i<arr.length;i++)
        {
            arr[i].close();
        }
    }
    
    </script>
    </head>
    
    <body>
    <div id="dd"></div>
    <span onClick="doopen()">打开5个子窗口</span>
    <span onclick="doclose()">关闭5个子窗口</span>
    
    </body>
    </html>
    View Code

    window.location.href="...";  跳转页面

    window.location.reload();  刷新页面

    document.getElementById();  根据id找

    document.getElementsByName();  根据name找

    document.getElementsByClassName();  根据class找

    document.getElementsByTagName();  根据标签找

    getAttribute()  获取属性

    setAttribute()  赋予属性

    removeAttribute()  移除属性

    表单元素  value

    非表单元素  innerHTML  innerText

  • 相关阅读:
    机器学习:K-近邻分类
    集体智慧编程2:聚类算法(分级聚类和K-均值聚类)(以博客的聚类为例,附有获取数据的代码)
    机器学习简介
    集体智慧编程1:推荐算法(基于协作性过滤collaborative filtering)(实例加代码)
    图片轮播
    A页面调到B页面,B页面关闭时A页面刷新
    css 上下滚动效果
    js数组的sort排序详解
    查看机器上安装的jdk能支持多大内存
    from表单如果未指定action,submit提交时候会执行当前url
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/6184677.html
Copyright © 2011-2022 走看看