Javascript - 替换'%20'空格 [英] Javascript - Replace '%20' spaces

查看:1133
本文介绍了Javascript - 替换'%20'空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var loc_array = document.location.href.split('/'); 
var linkElement = document.getElementById(waBackButton);
var newT = document.createTextNode(loc_array [loc_array.length-2]);
var repl = newT.replace('%20','');
linkElement.appendChild(repl);任何人知道为什么会导致文本不显示?





解决方案

为什么不只是

  unescape(document.location。 HREF); 


var loc_array = document.location.href.split('/');
var linkElement = document.getElementById("waBackButton");
var newT = document.createTextNode(loc_array[loc_array.length-2]); 
var repl = newT.replace('%20',' ');
linkElement.appendChild(repl);

Anyone know why this causes the text to not show up?

解决方案

Why not just do

unescape(document.location.href);

这篇关于Javascript - 替换'%20'空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆