And so why not simply use
<a href="localhost/OrderEntry/trainer/126.96.36.199/frameset.html ">Order Entry</a>
Presumbably, you are generating these links with some server-side code (PHP/ASP/JSP/etc.). No? So let the server side code do it.
<a onclick="this.href='localhost/' + this.innerHTML.replace(/\W/g,"") + '/trainer/188.8.131.52/frameset.html'; return true;">
The call to replace
there will remove all characters except letters, digits, and underlines from the text between the <a> and </a> tags.