Javascript:跳转到指定页面
<div>
<input type="text" id="jumpPage"/>
<input type="button" value="GO" onclick="Jump();" />
Total Pages:<input type="text" id="totalPages" value="{{ pages }}" />
</div>
<script>
function Jump() {
var val = document.getElementById('jumpPage').value.trim()
var totalPages = document.getElementById('totalPages').value.trim()
if(isNaN(val) || Number(val)<1 || Number(val)>Number(totalPages)||!(val.search(/\D/)===-1)){
alert("Please input a right page number")
document.getElementById('jumpPage').value = null
return false
}else{
location.href = "/index/"+val
}
}
</script>