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

  • 相关阅读:
    android11——Material Design
    android10——Internet
    Andrid09——Service
    Android08——MultiMedia
    Android07——ContentProvider
    Android06——Persistence
    <转>汇编源码调试
    编程中我犯过的错误一
    中国社会9大阶层划分,看看你在哪一层?
    汇编中如果汇编和调用API混合用的话要注意Pushad popad
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/6184677.html
Copyright © 2011-2022 走看看