行内代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum=1.0, user-scalable=no">
  8. <title>行内代码</title>
  9. </head>
  10. <body>
  11. <a href="javascript:console.log('Hello JavaScript');;">Hello JavaScript</a>
  12. </body>
  13. </html>

点击前
image.png

点击后
image.png

内嵌代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum=1.0, user-scalable=no">
  8. <title>内嵌代码</title>
  9. <script>
  10. console.log('Hello JavaScript');
  11. </script>
  12. </head>
  13. <body>
  14. </body>
  15. </html>

image.png

外部代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum=1.0, user-scalable=no">
  8. <title>外部代码</title>
  9. <script src="index.js"></script>
  10. </head>
  11. <body>
  12. </body>
  13. </html>
  1. console.log('Hello JavaScript');

image.png