随机链接

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p id="demo"></p>
  6.  
  7. <script>
  8. if (Math.random() < 0.5) {
  9. text = "<a href='https://baidu.com'>访问 baidu</a>";
  10. } else {
  11. text = "<a href='https://wwf.org'>访问 WWF</a>";
  12. }
  13. document.getElementById("demo").innerHTML = text;
  14. </script>
  15.  
  16. </body>
  17. </html>