使用URL时转换为十六进制.文档或window.location.href
Curly Brackets Converted to Hexidecimal when using URL.Document or window.location.href
要取文档。URL,找到带花括号的字符串,去掉花括号,只显示在花括号内的字符串。然而,似乎文件。URL或window.location.href将花括号转换为十六进制值(%7B &%7D),然后我无法匹配实际的{string}。如有任何帮助,不胜感激。
var txt = document.URL; // My URL is something like http://site.com/somepage&value0={string}
var re1='.*?'; // Non-greedy match on filler
var re2='(''{.*?''})'; // Curly Braces 1
var p = new RegExp(re1+re2,["i"]);
var m = p.exec(txt);
if (m != null)
{
var cbraces1=m[1];
document.write(cbraces1.replace("{","").replace("}",""));
}
先用decodeURI(document.URL)
var txt = decodeURI(document.URL);
unescape('%7B & %7D');
相关文章:
- window.location替换并传递URL历史记录条目中的变量
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- window.location使用jquery mobile实现chrome跳转
- Windows.Open 在 window.Location 工作时不起作用
- 如何将所有作业自定义到window.location.href
- window.location未刷新到现有URL
- 如果window.location.href.indexOf('player=1')添加样式
- 在$state.go之后执行$window.location.reload(true)
- javascript window.location在检查firebug时给了我一个错误的url路径
- angularjs 中 $window.location.reload() 和 $route.reload() 之间的区
- 在AJAX中使用window.location.replace'成功'回调
- IE中不支持JQuery window.location.hash
- PhoneGap如何在更改window.location/document.location后保持Javascript的
- 如何在更改window.location后停止执行
- 警报中的window.location必须重定向到上一页
- 如何在窗体操作或window.location(PHP)中使用数据切换
- 正在将目标添加到window.location
- window.location.htm无法在chrome扩展中工作
- 可以'当window.location.href时,无法从javascript获取post值
- 基于AJAX的网站中的JS window.location