javascript diverses

Still fooling around this the iyc2007 pages. And learning a bit of javascript.

Exactly, I was looking for a way to get the actual document absolute path, in order to link to the right page when writing many pages on different levels. Probably it’s no wonder for may people, but maybe someone is looking for the same answer i was looking for today.

So this is the code:


<script type="text/javascript">
var docPath = new String;
docPath = location.href.substring(0,location.href.lastIndexOf("/"));
document.write(location.href.substring(0,location.href.lastIndexOf("/")));
</script>

For this page, this is the output of the script:

Actually, I needed it to feed the flv mediaplayer with the path of the file, which behaves strangely if you feed it with relative path. This way gives the absolute path, as you can see.