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
  • 19,963
  • 14
  • 43
  • 67

1 Answers1

9

Why not just do

unescape(document.location.href);
Robusto
  • 30,482
  • 8
  • 54
  • 76
  • 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