test.html 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <HTML>
  2. <HEAD>
  3. <TITLE>WMI Scripting HTML</TITLE>
  4. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  5. <script>
  6. function validBrowser() {
  7. var u_agent = navigator.userAgent;
  8. var browser_name = 'Failed to identify the browser';
  9. if (u_agent.indexOf('Firefox') > -1) {
  10. browser_name = 'Firefox';
  11. } else if (u_agent.indexOf('Chrome') > -1) {
  12. browser_name = 'Chrome';
  13. } else if (u_agent.indexOf('Trident') > -1 && u_agent.indexOf('rv:11') > -1) {
  14. browser_name = 'IE11';
  15. } else if (u_agent.indexOf('MSIE') > -1 && u_agent.indexOf('Trident') > -1) {
  16. browser_name = 'IE(8-10)';
  17. } else if (u_agent.indexOf('MSIE') > -1) {
  18. browser_name = 'IE(6-7)';
  19. } else if (u_agent.indexOf('Opera') > -1) {
  20. browser_name = 'Opera';
  21. } else {
  22. browser_name += ',info:' + u_agent;
  23. }
  24. document.write('browser_name:' + browser_name + '<br>');
  25. document.write('u_agent:' + u_agent + '<br>');
  26. }
  27. var a = 1;
  28. if (!(b in window)) {
  29. var b = 2;
  30. a += 1
  31. } else {
  32. a += 2
  33. }
  34. console.log(a)
  35. console.log(b)
  36. </script>
  37. <body onload="validBrowser()">
  38. </body>
  39. </html>