doits
2016-03-10 22:00
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Mathint </title> <script type="text/javascript"> var i=Math.random()*10; function abc(){ document.write(Math.round(i)); } </script> </head> <body> <input type="button" value="刷新" onclick="abc()"> </body> </html>
需要用到location对象里的reload()方法。语法是:location.reload()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>编程练习</title>
<script>
var mynum=Math.random();
Math.round(mynum*10);
document.write(Math.round(mynum*10));
function contxt()
{
location.reload();
}
</script>
</head>
<body>
<button type="button" onclick="contxt()">点击这里</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mathint </title>
<script type="text/javascript">
function abc(){
var i=Math.random()*10;
document.getElementById("abc").innerText=Math.round(i);
}
</script>
</head>
<body>
<input type="button" value="刷新" onclick="abc()">
<div id="abc"><div>
</body>
</html>
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题