2
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?

balexander
  • 23,131
  • 14
  • 45
  • 68

1 Answers1

9

Why not just do

unescape(document.location.href);
Robusto
  • 31,447
  • 8
  • 56
  • 77
  • Where would that go though. I have .split() on the end. – balexander Jul 09 '10 at 17:28
  • I would unescape the string before you split it. Understand that if you use .split('\') on document.location.href, you are going to get some empty elements. Your array will look something like: `['http:','','www.someplace.com','dir1','subdir1','afile.htm?foo=bar&spork=spoon+fork']` – Robusto Jul 09 '10 at 17:40