手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >JavaScript使用encodeURI()和decodeURI()获取字符串值的方法
JavaScript使用encodeURI()和decodeURI()获取字符串值的方法
摘要:本文实例讲述了JavaScript使用encodeURI()和decodeURI()获取字符串值的方法。分享给大家供大家参考。具体如下:Ja...

本文实例讲述了JavaScript使用encodeURI()和decodeURI()获取字符串值的方法。分享给大家供大家参考。具体如下:

JavaScript使用encodeURI()和decodeURI()获取字符串值,不能就是地址栏显示的字串,以前经常在网上见到有人问此问题,无意在网上发现,不知是不是您想要的,先看看效果吧。

先来看看运行效果:

JavaScript使用encodeURI()和decodeURI()获取字符串值的方法1

具体代码如下:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>使用系统函数</title> <script language="JavaScript"> <!-- function showMsg() { var strURL= url.value; var encodeStr = encodeURI(strURL); var temp = encodeStr+"n"; temp += decodeURI(encodeStr); alert(temp); } --> </script> </head> <body> <div> 请输入一个URL:<input name="url" type="text" id="url" value="/search.php?keyword=搜索关键字" size="60" /> <input type="submit" name="button" id="button" value="我要提交" /></div> <dIV > <h2>使用encodeURI()和decodeURI()函数:</h2> </dIV> </body> </html>

希望本文所述对大家的javascript程序设计有所帮助。

【JavaScript使用encodeURI()和decodeURI()获取字符串值的方法】相关文章:

JavaScript实现点击文字切换登录窗口的方法

javascript实现行拖动的方法

JavaScript中停止执行setInterval和setTimeout事件的方法

JavaScript检测字符串中是否含有html标签实现方法

javascript实现设置、获取和删除Cookie的方法

JavaScript中reduce()方法的使用详解

JavaScript中使用Math.PI圆周率属性的方法

JavaSacript中charCodeAt()方法的使用详解

JavaScript获取两个数组交集的方法

jQuery获取字符串中出现最多的数

精品推荐
分类导航