zoukankan      html  css  js  c++  java
  • js 获取地址栏?后面的参数,实现文章栏目定位

    html:
    <div class="box">
        <ul>
              <li id="all">全部文章</li>
              <li id="category1">name1</li>
              <li id="category2">name2</li>   
        </ul>
    <div>
    

     js

    实例:www.xxx.com/index/article.html?url=all  获取all
    <script>
        function getRequest() {
            var url = window.location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for(var i = 0; i < strs.length; i ++) {
                    theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        $url = getRequest();
        if(!($url.url)){var init = document.getElementById('all').childNodes;init[0].style.color = 'rgb(35, 178, 148)';}else{ var child;child = document.getElementById($url.url).childNodes;child[0].style.color = 'rgb(35, 178, 148)';}
    </script>
    

      

      

  • 相关阅读:
    变量1
    PHP 函数
    发送post请求
    XXE
    CSRF
    Html基础
    暴力破解
    Brup sute
    XSS
    URL 传参转义 (特殊符号转义)
  • 原文地址:https://www.cnblogs.com/vilucky/p/13149418.html
Copyright © 2011-2022 走看看