zoukankan      html  css  js  c++  java
  • 获取URL的code的参数的值

    1、获取URL的code的参数的值

    需求说明:现在有URL为http://www.bdqn.cn/index.php?code=sdR4,请使用字符串对象的属性和方法来获取code的值,并把其指都转化为小写。

    js中实现字母大小写转换主要用到了四个js函数:

    1.toLocaleUpperCase
    2.toUpperCase
    3.toLocaleLowerCase
    4.toLowerCase

    下面就这四个实现大小写转换的js函数逐一做简单的分析。

    1.toLocaleUpperCase

    将字符串中所有的字母字符都将被转换为大写的,同时适应宿主环境的当前区域设置。

    2.toUpperCase

    将字符串中的所有字母都被转化为大写字母。

    3.toLocaleLowerCase

    将字符串所有的字母字符都被转换为小写,同时考虑到宿主环境的当前区域设置。

    4.toLowerCase

    将字符串中的字母被转换为小写字母。

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <html>
    <head>
        <title>获取URL中的code</title>
        <script type="text/javascript">
            function run(){
                //        获取href
                var href = document.getElementsByTagName("a")[0].getAttribute("href").valueOf();
    //            取到sdR4
                var code =href.substring(href.length-4,href.length);
    //            转小写
                var small = code.toLocaleLowerCase();
                document.getElementById("code").innerHTML ="超链接URL=后面数值小写为:"+small;
    
            }
    
        </script>
    </head>
    <body onload="run()">
        <a href="http://www.bdqn.cn/index.php?code=sdR4" name="url">超链接</a>
        <p id="code"></p>
    </body>
    </html>
  • 相关阅读:
    配置apache+php环境详解
    美剧推荐之《行尸走肉》
    代码轻松实现wordpress彩色标签云
    php配置支持mysql解决本地安装wordpress问题
    struts2通配符和动态方法调用
    struts2文件上传1
    struts2入门
    jQuery3
    ADT20安装报错
    Android入门
  • 原文地址:https://www.cnblogs.com/sincoolvip/p/5661332.html
Copyright © 2011-2022 走看看