75°

Javascript:跳转到指定页面

 1 <div>
 2     <input type="text" id="jumpPage"/>
 3     <input type="button" value="GO" onclick="Jump();" />
 4     Total Pages:<input type="text" id="totalPages" value="{{ pages }}" />
 5 </div>
 6 <script>
 7     function Jump() {
 8         var val = document.getElementById('jumpPage').value.trim()
 9         var totalPages = document.getElementById('totalPages').value.trim()
10         if(isNaN(val) || Number(val)<1 || Number(val)>Number(totalPages)|| !(Number(val) %1 === 0)){
11             alert("Please input a right page number")
12             document.getElementById('jumpPage').value = null
13             return false
14         }else{
15             location.href = "/index/"+val
16         }
17     }
18 </script>

 

本文转载自博客园,原文链接:https://www.cnblogs.com/DotSDot/p/13069120.html

全部评论: 0

    我有话说: