...

filename

twilight
07-08-2002, 09:40 AM
hi,
i have a page called page1.htm and i would like to use the page1 name within the document itself (i mean the page1.htm) so that i don't have to write page1 everytime

i would like to use it in this line:
<script language="javascript" src=page1.js></script>

i have multiple pages and the .js filename is always the same as the .htm filename.

could that be replaced with +filename+ or something like that (i'm just guessing here so don't laugh:D

mordred
07-08-2002, 11:07 AM
You could try

<script>
var file = location.pathname;

document.write("<script language=\"javascript\" src=\"" + file.substring(file.lastIndexOf("/") + 1, file.lastIndexOf(".")) + ".js\"><\/script>");
</script>

Note: This works only correct if you call the file from the server, not when you open it from the file system of Windows ('cause Windows use \ instead of /).

twilight
07-08-2002, 06:13 PM
thanks. it works just fine:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum