警示框+输入框+确认框

来源:互联网 发布:古筝考级教材知乎 编辑:程序博客网 时间:2024/04/30 16:06
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>js</title>
        <!--
            BOM
                browser object meodel  浏览器对象模型
                操作浏览器里面的功能。
                window
                    alert()警示框
                    prompt() 输入框
                    confirm() 确认框
                history  了解
                    前进 、下一页
                    后退
                    刷新
                location
                    定位
            
        -->
    </head>
    <body>
        
        <input type="button" id="id0" value="警示框" onclick="fangfa1()"/>
        
        <input type="button" id="id0" value="输入框" onclick="fangfa2()"/>
        <input type="button" id="id0" value="确认框" onclick="fangfa3()"/>
        <hr />
        <input type="button" id="id1" value="前进" onclick="fangfa4()"/>
        <input type="button" id="id2" value="后退" onclick="fangfa5()"/>
        <input type="button" id="id3" value="刷新" onclick="fangfa6()"/>
        <a href="http://baidu.com">百度一下</a>
        <a href="demo.html">京东</a>
        <hr />
        <input type="button" id="id4" value="定位" onclick="fangfa7()" />
        <script type="text/javascript">
            
            function fangfa1(){
                
                alert("hello 外面好冷");
                
            }
            
            
            function fangfa2(){
                
                //作用:获取用户的输入信息
                var qiu = prompt("请输入你喜欢的球类运动...");
                console.log(qiu+"----")
                
            }
            function fangfa3(){
                
                var a = confirm("确认删除吗?");
                console.log("---"+a);
                if (a) {
                    //删除
                }else{
                    //
                }
            }
            function fangfa4(){
                
                history.go(1);
//                history.forward();
                
            }
            function fangfa6(){
                history.go(0);
//                history.refresh(); 不存在
            }
            
            function fangfa7(){
                
                location.href="http://www.livecoding.tv";
                
            }
        </script>
        
    </body>
</html>

原创粉丝点击