结合if判断
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script> function buttonUrl(){ if(confirm('是否打开慕课网?')){ if(prompt('下面网址是慕课网官网吗?','http://www.imooc.com')){ open('http://www.imooc.com','_blank','width=400,height=600,menbar=no,toolbar=no'); } } } </script> </head> <body> <button onclick="buttonUrl()">弹弹弹</button> </body> </html>