码迷,mamicode.com
首页 > 编程语言 > 详细

javaScript特效

时间:2016-12-17 16:53:00      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:变量   add   baidu   doc   div   ide   size   forward   第一个   

技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <h1>第一个界面</h1>
  <a href="js02history.html">当前页面</a>
  <a href="js03history.html">下一个页面</a>
  <a href="javascript:history.forward()">forward()前进一个界面</a>
  <a href="javascript:history.go(1)">go(1)前进一个界面</a>
</body>
</html>
01.history属性界面1
技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <h1>第二个界面</h1>
    <a href="javascript:history.back()">back()后退一个界面</a>
    <a href="javascript:history.go(-1)">go(-1)后退一个界面</a>
</body>
</html>
history属性界面2

 

技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>

    <script type="text/javascript">
    document.write("host值为:"+location.host+"<br/>")
    document.write("hostname值为:"+location.hostname+"<br/>")
    document.write("href值为:"+location.href+"<br/>")
    document.write("hash值为:"+location.hash+"<br/>")
    document.write("search值为:"+location.search+"<br/>")
    </script>
</head>
<body>
    <input  type="text">
   <input type="button" value="刷新当前页面" onclick="location.reload()">
   <input type="button" value="替换当前页面" onclick="location.replace(‘http://www.bdqn.cn‘)">
</body>
</html>
02.location属性

 

技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        body{font-size:14px;
            line-height:30px;
        }
        input{margin:1px;
            width:90px;
            font-size:12px;
            padding:0;
        }
        #node{
            width:100px;
            font-size:24px;
            font-weight:bold;
            float: left;
        }
    </style>
<script type="text/javascript">
     /*改变层内容*/
    function changeLink(){
        document.getElementById("node").innerHTML="<h1>改变</h1>";
        //document.getElementById("node").innerText="<h1>改变</h1>";
    }
  /*获取所有input标签中所有的value*/
function all_input(){
   var allInput= document.getElementsByTagName("input");
    /*声明变量 接收所有input标签中所有的value*/
    var str="";
    for(var i=0;i<allInput.length;i++){
        str+=allInput[i].value+"<br/>";
    }
    /*把str获取的值 给  p标签*/
     document.getElementById("s").innerHTML=str;
}
  /*获取所有name属性值是season的value*/
function s_input(){
   var season= document.getElementsByName("season");
    /*声明变量 接收所有input标签中所有的value*/
    var str="";
    for(var i=0;i<season.length;i++){
        str+=season[i].value+"<br/>";
    }
    /*把str获取的值 给  p标签*/
     document.getElementById("s").innerHTML=str;
}
</script>
</head>
<body>
<div id="node">新浪</div>
<input name="b1" type="button" value="改变层内容" onclick="changeLink();" /><br />
<br /><input name="season" type="text" value="春" />
<input name="season" type="text" value="夏" />
<input name="season" type="text" value="秋" />
<input name="season" type="text" value="冬" />
<br /><input name="b2" type="button" value="显示input内容" onclick="all_input()" />
<input name="b3" type="button" value="显示season内容" onclick="s_input()" />
<p id="s"></p>
</body>
</html>
03.document

 

技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>window中的open()</title>
<script type="text/javascript">
  function  openNew(){
      window.open(
              "http://www.baidu.com",
              "百度页面",
              "height=400,width=400"
      );
  }
</script>
</head>
<body>

<input  type="button" value="打开新的窗口" onclick="openNew()">
</body>
</html>
04.open()

 

技术分享
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>定时函数</title>
<script type="text/javascript">
    var time=0;
    function count(){  //计数的方法
        document.getElementById("context").innerHTML="时间:"+(++time);

    }
  var interval,timeout;
    //定时函数
    function setI(){  //setInterval函数  周期执行
        interval=setInterval("count()",1000);
    }
    function setT(){  //setTimeout函数  执行一次
        timeout= setTimeout("count()",1000);
    }
    //清除定时函数
    function clearI(){//清除setInterval函数
        clearInterval(interval);
    }
    function clearT(){//清除setTimeout函数
        clearTimeout(timeout);
    }

</script>
</head>
<body>
  <div id="context"></div>
<input  type="button" value="setInterval函数" onclick="setI()">
<input  type="button" value="setTimeout函数" onclick="setT()"><br/>

  <input  type="button" value="清除setInterval函数" onclick="clearI()">
  <input  type="button" value="清除setTimeout函数" onclick="clearT()">
</body>
</html>
05.定时函数

 

javaScript特效

标签:变量   add   baidu   doc   div   ide   size   forward   第一个   

原文地址:http://www.cnblogs.com/999-/p/6189735.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!