have you tried passing the information as a query? because you are heavily relying on the browser to tell you what to do, and this can be tricky.. why not pass a query to the script to tell it what to strip?
He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.