`

javascript DOM

阅读更多
<!------------------///事件处理----------------------->
    <!--1-事件源对象所对应的HTML标签的事件属性
    
<script language="javascript">
        
///事件处理
        //1-事件源对象所对应的HTML标签的事件属性
        function hideContextmenu()
        
{
            window.event.returnValue
=false;
        }

    
</script>
    
<body oncontextmenu="hideContextmenu()">//oncontextmenu-右键关闭
    或<body oncontextmenu="return false">
        
    
</body>
    
-->
    
    
<!--2-在javascript代码中设置元素对象的事件属性
    
<script language="javascript">
        
//2-在javascript代码中设置元素对象的事件属性
        document.oncontextmenu=hideContextmenu;
        
function hideContextmenu()
        
{
            
return false;
        }

    
</script>
    
-->
    
    
<!--在一个专门的<script>标签对,用for属性指定事件源,event属性指定事件名
    
--常用于各种插件的处理
    
<script language="javascript" for="document" event="oncontextmenu">
    
//3-
        window.event.returnValue=false;
    
</script>
    
-->
    
    
<!------------------///window对象----------------------->
    <!--window的属性我方法的引用可以省略window.这个前缀-->
    
<script language="javascript">
        
//-1-alert()方法--显示OK提示对话框
        //-2-confirm()方法--显示带OK/cancel提示对话框,返加true或false
        /**//*if(confirm("您好吗?"))
        {
            alert("你好");
        }
        else
        {
            alert("您不好");
        }
*/

        
        
//-3-prompt()方法--输入信息对话框,返回本文
        /**//*var age=prompt("年龄","18");
        alert(age);
*/

        
        
//-4-navigate()方法--将当前窗口导航到一个新的url
        
        
//-5-setInterval()方法--设置每隔多长时间调用指定代码,执行多次
        
        
//-6-setTimeout()方法--设置多长时间后调用指定代码,只执行一次
        
        
//-7-clearInterval()方法--取消setInterval(),参数为setInterval()的返回值
        
        
//-8-clearTimeout()方法--取消setTimeout(),参数为setTimeout()的返回值
        
        
//-9-moveTo()方法--移动窗口
        
        
//-10-resizeTo()方法--改变窗口大小
        
        
//-11-open()方法
        
        
//-12-showModalDialog()方法--创建模态对话框,没有一般用window.open()打开的窗口的所有属性。

        
//-13-showModelessDialog()方法--方法用来创建一个显示HTML内容的非模态对话框。
        //window.open("information.html","_blank","top=0,left=0,width=200,height=200,toolbar=no");
</script>

    
<!------------------///window对象-frames数组对象----------------------->
        <!-- 
        
<frameset rows="20%,80%">
            
<frame name=top src="top.html">
            
<frame name=bottom src="bottom.html">
        
</frameset>
        
<input type=button value="刷新"
        onclick
="window.parent.frames[1].location.reload()">
         或onclick
="parent.frames.bottom.location.reload()">
         或onclick
="parent.frames[bottom].location.reload()">
         或onclick
="parent.frames.item(1).location.reload()">
         或onclick
="parent.frames.item('bottom').location.reload()">
         或onclick
="parent.bottom.location.reload()">
         或onclick
="parent[bottom].location.reload()">
    
-->
    
    
<!------------------///window对象-event对象----------------------->
    <script language="javascript">
    
//altKey属性
    //ctrlKey属性
    //shiftKey属性
    //clientX,clientY属性--
    //screenX,screenY属性
    //offsetX,offsetY属性
    //x,y属性
    //returnValue属性
    //cancelBubble属性
    //srcElement属性
    //keyCode属性
    /**//*function window_onkeypress()
    {
        alert(window.event.keyCode);
    }
    <body onkeypress=window_onkeypress()>
    </body>
*/

    
//button属性
    
    
//示例
    /**//*function checkCancel()
    {
        if(window.event.shiftKey)
            window.event.cancelBubble=true;
    }
    function showSrc()
    {
        if(window.event.srcElement.tagName=="IMG")
            alert(window.event.srcElement.src);
    }
    <body onclick="showSrc()">
        <img onclick="checkCancel()" src="aaa.gif">
    </body>
*/

    
</script>
    
    
<!------------------///window对象-事件----------------------->
    <script language="javascript">
        
//-onload事件
        
        
//-onunload事件
        
        
//-onbeforeunload事件
        /**//*<body onload="alert('欢迎')"  onunload="alert('再见')" 
        onbeforeunload="window.event.returnValue='小心'">
        </body>
*/

        
        
//-onclick事件
        
        
//-onmousemove事件
        
        
//-onmouseover事件
        
        
//-onmouseout事件
        
        
//-onmousedowm事件
        
        
//-onmouseup事件
        
        
//-onkeydown事件
        
        
//-onkeyup事件
        
        
//-onkeypress事件--用户按了数字或字母键所产生的事件
    </script>

    
<!------------------///window对象-属性----------------------->
    <script language="javascript">
        
//-closed属性--返回true/false
        
        
//-opener属性
        
        
//-defaultstatus属性
        
        
//-status属性
        
        
//-screenTop属性--返回当前窗口左上角顶点在屏幕上的垂直位置
        
        
//-screenLeft属性--返回当前窗口左上角顶点在屏幕上的水平位置
        
        
//////////子窗口调用父窗口的方法window.opener.start();
        /**//*var child = window.open("information.html","_blank",
                        "width=200,height=200,toolbar=no");
        function closeChild()
        {
            if(!child.closed)
                child.close();
        }
        var space_num=0;
        var dir=1;
        function scroll()
        {
            var str_space="";
            space_num=space_num+1*dir;
            if(space_num>40 || space_num<=0)
            {
                dir=-1*dir;
            }
            for(var i=0;i<=space_num;i++)
            {
                str_space += " ";
            }
            window.status=str_space+"www.it315.org";
        }
        function start()
        {
            setInterval("scroll()",100);
        }
        <body onload="start()">
        </body>
*/

    
</script>

    
<!------------------///window对象-子对象----------------------->
    <script language="javascript">
        
//-location对象--设置显示当前url
        //href属性
        /**//*window.location.href="http://www.it";
        等效于window.navigate("http://www.it");
*/

        
//replace()方法--载入一个url替代当前网页,基本同于href属性
        //reload()方法--刷新当前网页文档
        //opener.location.reload();//刷新父窗口
        
        
//-event对象
        
        
//-frames对象
        
        
//-screen对象
        
        
//-clipboardData对象
        
        
//-history对象
        
        
//-navigator对象
        
        
//-document对象
        //Cookie属性
        //基本格式:name=value
        //设置格式:name=value;expires=Fri,31 Dec 1999 23:59:59 GMT;path=/bookshop;domain=it315.org;secure
        //-expires字段  保存的有效时间,删除可以用设时间为以前来完成
        //没有设置expires将保存信息在内存中,关闭浏览器将消失
        //-domain字段  本cookie在那个域中有效,没有设置只对当前主机有效
        //-path字段  设置cookie在服务器上的那个目录下有效
        //没有设置path只在当前主机上的目录下有效
        //-secure字段  
        //读取格式:name1=value1;name2=value2
        
        
//-cookie value的解码头
        //javascript通常用escape和unescape函数
        /**//*var never = new Date();
        never.setTime(never.getTime()+10*365*24*60*60*1000);
        var expString="experes="+never.toGMTString()+";";
        document.cookie="area="+escape("北京海淀")+";"+expString;
        document.write("area="+'escape("北京海淀")'+";"+expString);
        document.cookie="zipcode=100080;"; 
*/

        
//读取cookie
        /**//*function getCookie(name)
        {
            var result=null;
            var myCookie=" "+document.cookie + ";";
            var searchName=" "+name+"=";
            var startOfCookie=myCookie.indexOf(searchName);
            var endOfCookie;
            if(startOfCookie != -1)
            {
                startOfCookie+=searchName.length;
                endOfCookie=myCookie.indexOf(";",startOfCookie);
                result=unescape(myCookie.substring(startOfCookie,endOfCookie));
            }
            return result;
        } 
        document.write(document.cookie+"<br>");
        document.write("are
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics