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