zoukankan      html  css  js  c++  java
  • 第三十八节 JavaScript中的window.location属性二

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Document</title>
     6     <script type="text/javascript">
     7         window.onload = function(){
     8             var oBody = document.getElementById('body01');
     9             var sData = window.location.search;  // 通过在地址后加?aa=1给值
    10             var hData = window.location.hash;  // 通过在地址后加#aa=1给值
    11             if (sData!='')
    12             {
    13                 var iRr = parseInt(sData.split('=')[1]);
    14                 if (iRr === 1)
    15                 {
    16                     oBody.style.backgroundColor = 'red';
    17                 }
    18                 else if(iRr == 2)
    19                 {
    20                     oBody.style.backgroundColor = 'green';
    21                 }
    22             }
    23         }
    24     </script>
    25     <style type="text/css">
    26         body{
    27             background-color: gold;
    28         }
    29     </style>
    30 </head>
    31 <body id="body01">
    32     
    33 </body>
    34 </html>
  • 相关阅读:
    Js变量类型
    前端面试题HTML
    AP聚类
    锚点
    html
    Active Learning主动学习
    z-index
    position
    学习笔记_卷积神经网络
    学习笔记_深度学习的数学基础
  • 原文地址:https://www.cnblogs.com/kogmaw/p/12493084.html
Copyright © 2011-2022 走看看