<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>随机数封装</title> </head> <body> <script type="text/javascript"> function suiji(up,down) { return Math.random()*(up-down + 1)+down; } var sj = parseInt(suiji(50,100)); alert(sj); </script> </body> </html>