Fix #250 by using a different approach to find the url of the current script

Brian, could you check if this works with the testview.html? It's a bit late and I don't have it set up