2017-04-24-第4次考试
Xplorist Lv6

2017-04-24-第4次考试

知识点1:

提交的两种方式:

submit提交

button提交

页面跳转:

js页面跳转

window.location.href=”url”;

【submit提交:】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script type="text/javascript">

    function sub( ){

      ````

      return true|false;

}

</script>



<form action="" onsubmit="return sub();" method="get|post" >

     <input type="text" >

     <input type="submit">

</form>

返回true则进入action指定的跳转页面;false则就不跳转页面


【button提交】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script type="text/javascript">

    function sub( ){

      var form1=document.getElementById("form1");

      if(){

       form1.submit();

}

      return true|false;

}

</script>



<form action=""  method="get|post"  id="form1">

     <input type="text" >

     <input type="button" onclick="sub()">

</form>

通过form对象的submit();方法来进行提交

还有form在js中一种很特殊的元素,可以不用documen来获取,可以直接同id来进行获取对象直接进行操作。

知识点2:

 评论