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>

最新文章

  1. Go语言 使用内置Http组件
  2. block,inline和inlinke-block细节对比
  3. [c++] STL = Standard Template Library
  4. Ue4如何在C++中获得获得当前角色的指针?
  5. cppcheck
  6. Location-aware Associated Data Placement for Geo-distributed Data-intensive Applications--INFOCOM 2015
  7. Omi教程-组件
  8. iOS开发之触摸事件及手势
  9. IDEA的热部署插件jrebel6.4.3离线安装版配置与破解
  10. 【集美大学1411_助教博客】团队作业6——展示博客(Alpha版本)
  11. Vue源码后记-其余内置指令(3)
  12. jquery mobile 表单提交 图片/文件 上传
  13. 42.输入一个递增排序的数组和一个数字S,在数组中查找两个数,使得他们的和正好是S, 如果有多对数字的和等于S,输出两个数的乘积最小的。
  14. python标准库之operator(运算符模块)
  15. 51Nod1577 异或凑数 线性基 构造
  16. Thrift源码学习二——Server层
  17. Mybatis 系列10-结合源码解析mybatis 的执行流程
  18. IDEA错误:Cannot start compilation: the output path is not specified for module &quot;Test&quot;. Specify the out
  19. Google Guava新手教程
  20. hdu2085-2086

热门文章

  1. WPF 绑定枚举值
  2. winform程序自动升级
  3. apache 伪静态配置
  4. MySQL 5.7.9版本sql_mode=only_full_group_by问题
  5. difference between append and appendTo
  6. 【BZOJ 4517】【SDOI 2016 Round1 Day2 T2】排列计数
  7. 控件(文本类): TextBlock
  8. SPDY 是什么?如何部署 SPDY?
  9. 【转】HTTP中的长连接和短连接分析
  10. HP新学知识